اذهب إلى المحتوى
  • 0

جافا

Tamer Abo Ali

السؤال

Recommended Posts

  • 1

يمكن ذلك كالتالي.. وإن كنت تقصد شيئ أخر الرجاء توضحه

import java.util.*;

 class Teacher{
     private int number;
     private String name;
     private int age;


    public Teacher(int number, String name, int age){
        this.number = number;
        this.name = name;
        this.age = age;
    }
    
    public String toString()
    {
        return this.getName()+"\n";
    }
    
    public String getName()
    {
        return this.name;
    }
    
    // .... Getters and Setters.
     
    public static void main(String[] args) {
        List<Teacher> teachers = new ArrayList<Teacher>();
        Scanner input = new Scanner(System.in);
        
        System.out.println ("Enter the name of the teacher");
        String teacherName= input.next();
        
        System.out.println ("Enter the number of the teacher");
        int teacherNumber= input.nextInt();
        
        System.out.println ("Enter the age of the teacher");
        int teacherAge= input.nextInt();
        
        Teacher t = new Teacher(teacherNumber, teacherName, teacherAge);
        teachers.add(t);

        for (Teacher teacher : teachers) { 		      
           System.out.println(teacher.toString()); 		
      }
    }
}

 

رابط هذا التعليق
شارك على الشبكات الإجتماعية

  • 0
اقتباس

مدرس teacher

Id

•Name

•dateOfBirth

•تخصص specialization

Crs_name

اقتباس

اعطيني الدوال الخاصة في المدرس

 

تم التعديل في بواسطة Tamer Abo Ali
رابط هذا التعليق
شارك على الشبكات الإجتماعية

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...