1 Description of the Program In this assignment, you will make two classes, FullTime Employee and PartTimeEmployee, that inherit from a superclass Employee. The implementation of class Employee is given. You will also need to write a test program to test the methods you write for these two classes. The implementation details are described as follows. Stage1: In the first file Full TimeEmployee.java, you should include the following addi- tional instance variables and methods (other than all instance variables and methods inher- ited from class Employee): Private instance variable weeklySalary: • A constructor takes four inputs (firstname, lastname, SSN and salary); • One additional getter method to return the instance variable (accessor); One setter method to set the instance variable (mutator); • One overriding method earnings () that returns the weekly earnings (should be as same as the getSalary() method); A method toString that converts an fulltime employee's information into string form (including firstname, last name, ssn, earning and class name). The string should have a neat output format as shown in Figure 1. You should override superclass toString() method. Stage2: In the second file Part Time Employee.java, you should include the following addi- tional instance variables and methods (other than all instance variables and methods inher- ited from class Employee): Private instance variables wage (wage per hour) and hours (hours worked for week); • A constructor takes five inputs: firstname, firstname, SSN, hours, and wage; Two additional getter methods to return the instance variables (accessor); • Two setter methods to set the instance variables (mutator);
Go off this code:
public abstract class Employee
{
private String firstName;
private String lastName;
private String SSN;
double salary;
public Employee( String first, String last, String ssn )
{
firstName = first;
lastName = last;
SSN = ssn;
}
public void setfirstName( String first )
{
firstName = first; // should validate
}
public String getfirstName()
{
return firstName;
}
public void setlastName( String last )
{
lastName = last; // should validate
}
public String getlastName()
{
return lastName;
}
public void setSSN( String ssn )
{
this.SSN = ssn;
}
public String getSSN()
{
return SSN;
}
@Override
public String toString()
{
return String.format( "%-12s%-12s%-12s", getfirstName(), getlastName(), getSSN() );
}
public abstract double earnings();
}
![**Transcription for Educational Website:**
- **Earnings Method:** A method named `earnings()` is implemented to return an employee's earnings based on hours worked and wage. For hours exceeding 40, employees receive time-and-a-half pay. Users must compare their output with Figure 1 for accuracy.
- **toString Method:** A method named `toString` is used to convert a part-time employee’s information into a formatted string (including first name, last name, social security number, earnings, and class name). The string must match the neat output format shown in Figure 1. Users should override the superclass’s `toString()` method.
**Figure Description:**
Figure 1 displays a screenshot of the program's output. It shows a list of employees with their earnings and class types:
```
---------------------------------------------------------------------------
A List of Employees, Earnings and Class Types:
---------------------------------------------------------------------------
John Smith 333-44-9982 $800.50 FullTimeEmployee
Larry Lippert 449-22-2340 $250.20 PartTimeEmployee
Sally Kelly 700-33-5511 $420.00 PartTimeEmployee
Smith Wilson 880-25-3412 $1,250.00 FullTimeEmployee
Darren Weber 594-98-3411 $550.00 PartTimeEmployee
Ashley Parker 888-33-3399 $1,195.00 FullTimeEmployee
```
**Stage 3 Instructions:**
1. **Array Creation:** In the file `EmployeeTester.java`, an array of type `Employee`, with a size of 10, should be created. This array is for storing references for subclass objects (`FullTimeEmployee`, `PartTimeEmployee`). This array usage demonstrates Polymorphism.
2. **Object Initialization:**
- Initialize each array object using data from the file "data.txt."
- **Important:** Use a `Scanner` object to read input from the file; manual object initialization is not allowed.
- The first value in each line determines the object type: `1` for `FullTimeEmployee` and `2` for `PartTimeEmployee`. Based on this value, create the corresponding object.
- Populate the remainder of the instance variables with the line values for that object type.
3. **Output Display:** Use the `toString()`](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ffa5ca6d3-7e28-4545-b49f-c13c41c00283%2F31d0e7d1-34a6-44b3-bdbc-7e78247cb249%2Fv6ye7u_processed.png&w=3840&q=75)
![# Description of the Program
In this assignment, you will make two classes, `FullTimeEmployee` and `PartTimeEmployee`, that inherit from a superclass `Employee`. The implementation of class `Employee` is given. You will also need to write a test program to test the methods you write for these two classes. The implementation details are described as follows.
**Stage1:** In the first file `FullTimeEmployee.java`, you should include the following additional instance variables and methods (other than all instance variables and methods inherited from class `Employee`):
- **Private instance variable** `weeklySalary`;
- **A constructor** takes four inputs (`firstname`, `lastname`, `SSN` and `salary`);
- **One additional getter** method to return the instance variable (accessor);
- **One setter method** to set the instance variable (mutator);
- **One overriding method** `earnings()` that returns the weekly earnings (should be the same as the `getSalary()` method);
- A method `toString` that converts a full-time employee’s information into string form (including firstname, lastname, ssn, earning and class name). The string should have a neat output format as shown in Figure 1. You should override superclass `toString()` method.
**Stage2:** In the second file `PartTimeEmployee.java`, you should include the following additional instance variables and methods (other than all instance variables and methods inherited from class `Employee`):
- **Private instance variables** `wage` (wage per hour) and `hours` (hours worked for week);
- **A constructor** takes five inputs: `firstname`, `lastname`, `SSN`, `hours`, and `wage`;
- **Two additional getter** methods to return the instance variables (accessor);
- **Two setter methods** to set the instance variables (mutator);](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ffa5ca6d3-7e28-4545-b49f-c13c41c00283%2F31d0e7d1-34a6-44b3-bdbc-7e78247cb249%2F1zkpmno_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
As per the given question, given the Employee class, we need to implement FullTimeEmployee, PartTimeEmployee, and EmployeeTester classes.
Both FullTimeEmployee and PartTimeEmployee classes inherit the Employee class.
Inside the EmployeeTester class, create an array of Employee class objects and then based on the first value in each line of the file.
Step by step
Solved in 6 steps with 5 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)