Question
This is for Java. For this assignment, you will use inheritance. Your project should include four classes as described below. 1. Create a class that
This is for Java.
For this assignment, you will use inheritance. Your project should include four classes as described below.
1. Create a class that contains the main method. This class should have a main method (required) and can have more static methods (optional). The method(s) should perform the following tasks: a) Create an object/instance of the employee class, an object of the salaried class and an object of the contractor class (described below). You will have a minimum of 3 objects (1 employee, 1 salaried, 1 contractor). b) Create an array of employee objects. Put all instances of the employee class, salaried class and contractor class into the array. c) Call the payCheck method with each employee object in the array and display the returning string.
2. Create a class called employee that includes: a) A constructor that accepts parameters for the instance variables b) Instance variables to hold the name and SSN of an employee c) Accessor methods for each of the instance variables d) A payCheck function that returns a string that includes the employee name and SSN.
3. Create a class called FTE for Full Time Employees that inherits from the employee class and includes: a) Instance variable to hold the employee's salary b) A constructor that accepts the name, SSN and salary of an employee. This constructor should call the employee class constructor to set the name and SSN. The constructor should also set the salary instance variable. c) Override the payCheck function to return a string that includes this information: employee name, SSN and the salary divided by 12. This will be a monthly paycheck.
4. Write a class called contractor that inherits from the employee class that includes: a) Instance variable to hold the contractor's hourly pay rate. b) A constructor that accepts the name, SSN, and pay rate as parameters. The constructor should call the employee class constructor to set the name and SSN. The constructor should also set the pay rate instance variable. c) A payCheck method that accepts the hours worked as a parameter. This method should return a string that includes the contractor's name, SSN and the total pay, which should be calculated by multiplying the pay rate times the hours worked. Hint: You will need to overload payCheck in the parent class and then override it in the constructor class.
Note: You can add additional methods as needed.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started