For this assignment, you will write a class and a subclass. The
files you will submit via turnin are:
Write an Employee class. The public methods in this class should be:
1. A constructor that takes the first name, last name, monthly salary (a double) as arguments.
2. A getFirstName() method that returns the first name of the employee.
3. A getLastName() method that returns the last name of the employee.
4. toString() method, overriding the version inherited from the Object class.
5. A getSalary() method that returns the employee's monthly salary.
6. An earnings() method that returns the employee's annual salary.
Write a Boss class that inherits from Employee. The public methods
the class should be:
1. A constructor that takes a first name, last name, monthly salary and annual bonus as arguments, and passes the first name, last name and monthly salary to the Employee's constructor to initialize its firstName, lastName, and monthly salary members.
2. An earnings method that returns the boss's annual income (annual salary + bonus). This method overrides the version inherited from the parent class, Employee.
3. A toString method that returns a String containing the type of employee (i.e. "Boss: ") followed by the boss's name and annual income.
The data members of both the Employee class and Boss class should be private.
Write a TestEmployee class to test these two classes. Your TestEmployee class will read employee information from a text file called "employee.txt" with the following format:
<number indicating whether or not employee 1 is a boss -- 0 = no,
<employee 1's first name>
<employee 1's last name>
<employee 1's monthly salary>
<employee 1's annual bonus, if employee 1 is a boss>
<number indicating whether or not employee 2 is a boss>
For example, your file might look like this:
The TestEmployee class assigns the information for each employee to an Employee instance, and prints a list of employees to the screen using the appropriate methods in the other two classes. That is, do NOT read the information from the file and then just print it to the screen; read the employee information from the file, and store it in an Employee instance. Then display the desired information from the Employee instance by using the Employee methods.
annual earnings: $25000
Boss: Harry Hacker
annual earnings: $70000
Boss: Tiger Woods
annual earnings: $500000
Your class should process all employees represented in the file in this way. Turn in the "employee.txt" file that you use to test your program. You will be graded in part on how thoroughly you tested your program.
Each class should contain documentation that states your name, EID,
and a brief description of the class. Variables should
have meaningful names, and you should include comments as needed to
readability of your program. Your files must be submitted by 9 pm on
the due date.