Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create two classes - 'FullTimeEmployee' and 'PartTimeEmployee', which inherit from a superclass 'Employee'. Write a test program to test the methods you write for the

Create two classes - 'FullTimeEmployee' and 'PartTimeEmployee', which inherit from a superclass 'Employee'. Write a test program to test the methods you write for the two classes.

In FullTimeEmployee, include the following 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 (same as the getSalary() method);

A method toString that converts a fulltime employee's information into string form (including firstname, lastname, ssn, earning, and class name).Override superclass toString() method.

In the second file 'PartTimeEmployee.java', 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);

One overriding method 'earnings()' that returns the earnings based on hours and wage. For hours in excess of 40 hours, the pay will be time-and-a-half.

A method 'toString' that converts a parttime employee's information into string form (including firstname, lastname, ssn, earnings, and class name). Override superclass toString() method.

In the third file 'EmployeeTester.java', do the following:

Create an array of Employee type, with the array size of 10. Use this array to store the references for subclass objects (FullTimeEmployee, PartTimeEmployee).

Initialize each object of the array using the values from the file of "data.txt" (Read the values in from the file using the Scanner object, do not initialize them manually).

The first value in each line of the file could be 1 (FullTimeEmployee) or 2 (PartTimeEmployee), which will be used to determine which kind of object you will initialize. The reamining values of the lines will be used to initialize each instance variable of that particular type of the object.

Print out the contents of each element (i.e., object) in the array using toString() method.

This program needs to be in Java.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PC Magazine Guide To Client Server Databases

Authors: Joe Salemi

1st Edition

156276070X, 978-1562760700

More Books

Students also viewed these Databases questions

Question

LO5 Illustrate the steps in developing a base pay system.

Answered: 1 week ago