Question: Implement your code: In this question, you are required to complete four classes: Employee, StudentWorker, Faculty, and FileOperator. The Employee class is an abstract super

Implement your code:

In this question, you are required to complete four classes: Employee, StudentWorker, Faculty, and FileOperator. The Employee class is an abstract super class that represents plain employees and the StudentWorker and Faculty classes are concrete subclasses that inherit from the Employee class. The FileOperator class saves the content of an Employee array into a physical file on the disk.

For the Employee class, implement the following:

A private String instance variable m_name. A private String instance variable m_department.

A constructor that takes two parameters (in the order of name, department) and sets the instance variables. A getter method for m_name and a getter method for m_department. An abstract String method named getPaycheck that does not take any parameter.

For the StudentWorker class, implement the following:

A private int instance variable m_hours. A private int instance variable m_hourlyWage.

A constructor that takes four parameters (in the order of name, department, hours, hourly wage). It should use the parameters for hours and hourly wage to set the m_hours and m_hourlyWage instance variables and then explicitly call the parent class constructor using the super keyword and pass in the two other parameters. A getPaycheck method that implements the same method in the Employee class. It calculates the paycheck amount (m_hours m_hourlyWage) and returns the student workers paycheck as a string in the following format. Note that the three fields are separated by a hyphen, represented by the minus character. Do NOT add spaces before or after each hyphen. There are no commas in the number. See example:

 Optimus Prime-Computer Science-$1200 

For the Faculty class, implement the following:

A private int instance variable m_salary. A constructor that takes three parameters (in the order of name, department, salary). It

should use the parameter for salary to set the m_salary instance variable and then explicitly call the parent class constructor using the super keyword and pass in the two other parameters. A getPaycheck method that implements the same method in the Employee class. It returns the faculty members paycheck as a string in the following format (the amount of money is equal to m_salary) See example:

 Pooh-Mathematics-$50000 

For the FileOperator class, the class skeleton is already provided to you. The only method you should modify and implement is writeFile. This method takes an array of employees, and each element can be a Faculty object or a StudentWorker object. Your task is to identify the type of the object using the instanceof keyword and write a line representing this object to the file using reference m_file. If the current object is a Faculty, then add a prefix F- to the string returned by getPaycheck and write this line to the file. Otherwise, if the current object is a StudentWorker, the prefix should be S-. For example:

 S-Optimus Prime-Computer Science-$1200 F-Pooh-Mathematics-$50000 

Test your code:

You are provided with a test driver implemented in "TestEmployees.java" (do not make any changes to this file!) so there is no need to write your own testing code.

Once you have completed the above classes, you can run the test. You should create a plain text file named "output.txt", copy and paste the output (if your code crashes or does not compile, copy and paste the error messages) to this file and save it.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!