So I’ve been working with inheritance and I’ve run into a problem. I’m very new to the super and extends commands and there is porbably an obvious error with syntax that I am just missing. Basically I have 5 classes, one super, three subs and 1 tester class. Everything looked good until I tried to run the tester class, and where I hoped to find the data entered when instantiating the variables, I instead got null values back. I need to know if this is a problem with how I declared them, or if it’s simply a problem with my super and sub classes. Any advice you can give for this would be greatly appreciated.
In an attempt not to fill up the screen, I’ve included my super and sub classes in this paste bin:
Super: http://pastebin.com/eZLXvknz
Sub1: http://pastebin.com/PFgApK3Y
Sub2: http://pastebin.com/QKDjB9g4
Here is my tester class:
public class EmployeeTest {
public static void main(String[] args){
Employee [] employeeArray = new Employee[3] ;
SalariedEmployee employee1 = new SalariedEmployee("Andrea", "Doroshenko", "111-111-111", 6, 2011, 2400);
CommissionedEmployee employee2 = new CommissionedEmployee("Nick", "McRae", "222-222-222", 1, 1998, 50000, 0.1);
SalPlusCommEmployee employee3 = new SalPlusCommEmployee("Dan", "Mills", "333-333-333", 3, 2011, 1000, 0.05, 500 );
employeeArray[0] = employee1;
employeeArray[1] = employee2;
employeeArray[2] = employee3;
System.out.println(employee1.getEmployeeDetails());
System.out.println(employee2.getEmployeeDetails());
System.out.println(employee3.getEmployeeDetails());
}
//end main
}
//end class
I figure that the porblem is either going to be with the tester or the super, but included the others just in case. I know that right now the array seems pointless, but I will need it later on, so that’s why it’s there. Thanks again for any help you guys can give!
In your
Employeeconstructor, you do not initialize employee features. That’s all. Initialize them.