Java Reference
In-Depth Information
((Contractor) company[i]).setDaysWorked(5);
}
}
SmartBoss boss = new SmartBoss();
System.out.println(“Paying each employee”);
for(int i = 0; i < company.length; i++)
{
boss.payEmployee(company[i]);
}
}
}
The payEmployee() method in SmartBoss has an Employee parameter, so all
the elements in the company array can be passed in. Within payEmployee(),
the computePay() and mailCheck() methods are invoked on the Employee
passed in; and by virtual method invocation, the appropriate computePay()
method is invoked on each of the 200 Employee objects.
Because the MyCompany program generates random types of employees,
the output will look different each time the program is executed. Figure 9.5
shows an example of its output.
Figure 9.5
Sample output of the MyCompany program.
Search WWH ::




Custom Search