abstract class Person
{
String name;
int age;
}
class Employee extends Person
{
String subordinate_id;
String department;
int rank;
public Employee(String name, int age, String subordinate_id, String department, int rank)
{
this.name = name;
this.age = age;
this.subordinate_id = subordinate_id;
this.department = department;
this.rank = rank;
}
public void print()
{
System.out.println("I am a Employee");
System.out.printf("My name is %s,I am %d years old.\n",name, age);
System.out.printf("I am a %d level Employee.My employeeNumber is %s.I am working in %s\n",rank, subordinate_id, department);
}
}
class Manager extends Employee
{
Vector subordinate = new Vector<Object>();
public Manager(String name, int age, String subordinate_id, String department, int rank)
{
this.name = name;
this.age = age;
this.subordinate_id = subordinate_id;
this.department = department;
this.rank = rank;
}
public void print()
{
System.out.println("I am a Employee");
System.out.printf("My name is %s,I am %d years old.",name, age);
System.out.printf("I am a %d level Employee.My employeeNumber is %s.I am working in %s",rank, subordinate_id, department);
System.out.println("My subordinate has:");
}
}
//the main was given to me in the question to solve for the rest of the code
class Main
{
public static void main(String[] args)
{
Employee e1 = new Employee("zhangsan", 20, "s101", "d01", 3);
e1.print();
System.out.println();
Employee e2 = new Employee("lisi", 20, "s202", "d02", 4);
e2.print();
System.out.println();
e2 = new Employee("maliu", 20, "s102", "d01", 5);
e2.print();
Manager m1 = new Manager("wangwu", 30, "s100", "d01", 9);
m1.getSubordinates().addElement(e1);
m1.getSubordinates().addElement(e2);
m1.print();
System.out.println();
}
}
Мне дали основной метод и попросили придумать остальную часть кода, есть три класса, класс Person, класс Employee.и менеджер класса. у менеджера класса есть подчиненный векторный тип в соответствии с вопросом ..... я не смог понять getsubordinate (). addElement ();в основном, что означает эта строка?