This is the question , i will upload my code later , pls help me check what are the mistake that i done ... thx ^^
Write a Java class named Employee. This class should have the following private instance variables:
• an ID value
• the name of a person associated with the Employee
• a field to store a value for the annual salary
• a field to store a reference to another Employee object (for the Employee’s boss, eventually)
Write methods with the following signatures:
• a public constructor for the class that will insure that Employee objects always have a ID and name fields with the signature:
public Employee(int id, String name)
• a method to calculate an Employee object’s salary field with the signature:
public double calAnnualSalary(double monthlySal, double allowances, double tax
)
Annual salary calculation:
Gross salary = 12 x monthlysal
Annual salary = [Gross salary + allowances]-[gross salary x tax]
Note* - tax in percentage
• a method to get an Employee object’s current salary field value with the signature:
public double getSalary( )
• a method to set an Employee object’s field referencing another Employee object with the signature:
public void setBoss ( Employee boss )
• a method to return a String identifying the field contents of an Employee with the signature
public String toString()
You also need to write a Java class named Boss. This class will make use of the Employee class created above. Your Boss class should have the following private instance variables:
• a bossName
• an array named employees in which to store Employee objects
• an int field named count to store the number of Employees who the Boss has.
Write methods with the following signatures:
• a public constructor for the class that will insure that Boss objects always have a name field with the signature.
public Boss( String name )
This constructor should also instantiate an array to store Employee objects (at least 60) and initialize the count of employee’s to 0. It should not initialize the array contents; just create the array.
• An appropriate accessor method (for example: getBossName())
• a method to add an Employee object to the array of Employees with the signature
public void hire( Employee emp )
This method should increase the count of Employees associated with the Boss as each Employee is added.
• a method that will cause the Boss to hire a group of people. This method should have the signature
public void staffUp()
This method should create a number of Employee objects (at least 5) and then use the hire method to add them to the boss. You may use any names and id values you choose. One way to initialize a group of names to use would be to get them from an array that is initialized like:
String [] names = {"John", "Paul", "George", "Ringo", "Fred" };
You may use these names or any of your choosing and any technigue of your choosing to give each Employee a different name as an input parameter for your Employee constructor. Use any id values you choose.
• a method to print out the Boss name followed by the names of the Employees who are managed by a Boss in an order different than they were added. This method should have the signature:
public void list()
You also need to write a BossEmployeeDemo class that contains a main() method. The main method for this class should:
1. create a single instance of the Boss class,
2. call the staffUp method on the Boss object
- ask user to input Employee name and ID
3. call the list method on the Boss object
4. Be sure that you also invoke appropriate methods in Employee class when you need to hire a staff.[COLOR="Silver"]