Here I am creating the objects and try to print them,I have differnt classes for date and Employee.The objects EmplObj and EmplObj2 ,are created but I have problem when I tried to print them ,it is printing only the first one
public class tester {
public static void main(String args[]){
EmployeeList EmplObj=new EmployeeList();
EmplObj.addEmplyee("Steve",34,45,new Date(1,1,2011));
EmployeeList EmplObj2=new EmployeeList();
EmplObj2.addEmplyee("Jenifer",35,45,new Date(1,3,2011));
EmployeeList.printAll();
}
}
public class EmployeeList {
int capacity; //The capacity of the list
static int count=0; //The number of the employees currently in the list
Employee[] employees;
public EmployeeList(){
employees=new Employee[5];
}
public EmployeeList(int capacity) {
employees=new Employee[capacity];
}
public void addEmployee(Employee e){
employees[count]=new Employee();
}
public void addEmplyee(String name,double hours,double hourlyRate,Date date){
employees[count]=new Employee(name,hours,hourlyRate,new Date());
count++;
}
public void addEmplyee(String name,double hours,double hourlyRate,int year,int month,int day){
employees[count]=new Employee(name,hours,hourlyRate,new Date(day,month,year));
count++;
}
public void printAll(){
for(count=0;employees[count]!=null;count++){
System.out.println(employees[count]);
}
}
}