我正在尝试创建一个无参数构造函数,它将从用户(通过 Scanner 类)获取所有实例变量的输入,但它是从另一个类继承的。
我该怎么做呢?
这是我所做的:
public class Manager extends Super_Employee{
String manager ;
/* String GetManger (){
return manager ;
}*/
Manager (){
Scanner manager = new Scanner(System.in);
}
@Override
String Print() {
return ("the manager is : " +manager);
}
这是超级类:
public class Super_Employee extends abstract_Employee {
String Fname ;
String Lname;
String address;
int number;
Super_Employee(String Fname,String Lname, String address, int number)
{
System.out.println("Constructing an Employee");
this.Fname = Fname ;
this.Lname = Lname;
this.address = address;
this.number = number;
}
@Override
String Print (){
return ("the employee name is : "+Fname+ " "+ Lname+ " ,the Employee address is : "
+ address + " ,the employee Phone # : "+number);
}
}