I am trying to create a no argument constructor that will take inputs from the user (via the Scanner class) for all of the instance variables, but it is inherited from another class.
How do I do this?
Here is what I did:
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);
}
here is the super class:
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);
}
}
Add a no-arg constructor in
Super_EmployeeSince, you have
the compiler doesn’t provide a default constructor (which is a no-arg constructor provided by the constructor itself).