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);

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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()`
Transcribed Image Text:**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()`
# 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);
Transcribed Image Text:# 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);
Expert Solution
Step 1

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.

steps

Step by step

Solved in 6 steps with 5 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY