The Inheritance hierarchy is as follows:  (Be sure to create this hierarchy correctly and efficiently; taking advantage of inheritance, polymorphism and exception handling concepts discussed in previous modules) A company pays its personnel on a weekly basis.  The personnel are of 4 types:  FixedWeekly personnel are paid a fixed amount regardless of the number of hours worked ByTheHour  personnel are paid by the hour and receive overtime pay for all hours worked in excess of 40 PercentOfSales personnel are paid a percentage of their sales FixedWeeklyPercentOfSales personnel receive a fixed amount plus a percentage of their sales. All variables are private, thus all of them will have public getters and setters Create a class called Personnel.  This class will represent the general concept of all personnel.  All 4 types of personnel are considered Personnel.  FixedWeeklyPercentOfSales personnel are considered to be PercentOfSales Personnel.   The Personnel class will also be Payable.  You will need to create the Payable interface.  It will contain just one method called earnings().   Personnel have a first name, last name, and social security number.  FixedWeekly personnel have a first name, last name, social security number and fixed weekly salary.  ByTheHour personnel have a first name, last name, social security number, an hourly wage, and number of hours worked.  PercentOfSales personnel have a first name, last name, social security number, gross sales amount, and commission rate.  FixedWeeklyPercentOfSales personnel have a first name, last name, social security number, gross sales amount, commission rate and a fixed weekly salary

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

Code in JAVA and please see attached images on specifications

The Inheritance hierarchy is as follows:  (Be sure to create this hierarchy correctly and efficiently; taking advantage of inheritance, polymorphism and exception handling concepts discussed in previous modules)

A company pays its personnel on a weekly basis.  The personnel are of 4 types: 

FixedWeekly personnel are paid a fixed amount regardless of the number of hours worked
ByTheHour  personnel are paid by the hour and receive overtime pay for all hours worked in excess of 40
PercentOfSales personnel are paid a percentage of their sales
FixedWeeklyPercentOfSales personnel receive a fixed amount plus a percentage of their sales.
All variables are private, thus all of them will have public getters and setters

Create a class called Personnel.  This class will represent the general concept of all personnel.  All 4 types of personnel are considered Personnel.  FixedWeeklyPercentOfSales personnel are considered to be PercentOfSales Personnel.  

The Personnel class will also be Payable.  You will need to create the Payable interface.  It will contain just one method called earnings().  

Personnel have a first name, last name, and social security number.  FixedWeekly personnel have a first name, last name, social security number and fixed weekly salary.  ByTheHour personnel have a first name, last name, social security number, an hourly wage, and number of hours worked.  PercentOfSales personnel have a first name, last name, social security number, gross sales amount, and commission rate.  FixedWeeklyPercentOfSales personnel have a first name, last name, social security number, gross sales amount, commission rate and a fixed weekly salary.

The Personnel class will contain an appropriate 3 parameter constructor and a default constructor,
appropriate accessors and mutators, toString, and equals methods. Two Personnel will be considered
equal if their earnings are the same. It will also contain an earnings method which must be
implemented by the subclasses. The constructor will validate that the social security number is in the
proper format (999-99-9999). If not in the proper format, the constructor will assign XXX-XX-XXXX for
the social security number. (you can do this using appropriate methods of the String class or by using
what are called Regular Expressions...it might be easier to just use methods from the String class rather
than learning about Regular Expressions - your choice)
The FixedWeekly class will contain an appropriate 4 parameter constructor and a default constructor,
appropriate accessors and mutators, earnings, toString, and equals methods. You decide whether you
need to override or simply inherit methods from the super class. The constructor will validate that the
fixed weekly salary is not negative. If the salary figure is negative the fixed weekly salary value will be set
to 0. (Create a own NotNegative Exception class for the program to handle negative numbers)
The ByTheHour class will contain an appropriate 5 parameter constructor and a default constructor,
appropriate accessors and mutators, earnings, toString, and equals methods. You decide whether you
need to override or simply inherit methods from the super class. The constructor will validate that the
hourly wage is not negative and that the hours worked is between 0 and 60 inclusive. If the hourly wage
is negative set the hourly wage to 0. If hours worked is not in the proper range, set the hours worked to
0.
The PercentOfSales class will contain an appropriate 5 parameter constructor and a default constructor,
appropriate accessors and mutators, earnings, toString, and equals methods. You decide whether you
need to override or simply inherit methods from the super class. The constructor will validate that the
gross sales amount is not negative and that the commission rate is a value between 0.0 and 1.0 inclusive.
If these conditions are not met then set the appropriate variable values to 0.
The FixedWeekly PercentOfSales class will contain an appropriate 6 parameter constructor and a default
constructor, appropriate accessors and mutators, earnings, toString, and equals methods. You decide
whether you need to override or simply inherit methods from the super class. The constructor will
validate that the fixed weekly salary amount is not negative. If the fixed weekly salary is negative set the
appropriate variable value to 0.
Write a class to test your inheritance hierarchy. In that class do the following: (Inheritance Demo.java)
Create 4 Personnel objects. Use the below information
The Test Data is in a File called personnel.txt and contains the following data:
fixed Harry Clark 111-11-1111 800.00
hour Katie Brown 222-22-2222 16.75 40
percent Joan White, 333-33-3333 10000 .06
fxdpercent Bob Green 444-44-4444 5000 .04 300
The first token in each line in the data file represents a code for the type of Personnel
●
fixed - FixedWeekly
●
hour-ByTheHour
percent PercentOfSales
fxdpercent - Fixed WeeklyPercentOfSales
Transcribed Image Text:The Personnel class will contain an appropriate 3 parameter constructor and a default constructor, appropriate accessors and mutators, toString, and equals methods. Two Personnel will be considered equal if their earnings are the same. It will also contain an earnings method which must be implemented by the subclasses. The constructor will validate that the social security number is in the proper format (999-99-9999). If not in the proper format, the constructor will assign XXX-XX-XXXX for the social security number. (you can do this using appropriate methods of the String class or by using what are called Regular Expressions...it might be easier to just use methods from the String class rather than learning about Regular Expressions - your choice) The FixedWeekly class will contain an appropriate 4 parameter constructor and a default constructor, appropriate accessors and mutators, earnings, toString, and equals methods. You decide whether you need to override or simply inherit methods from the super class. The constructor will validate that the fixed weekly salary is not negative. If the salary figure is negative the fixed weekly salary value will be set to 0. (Create a own NotNegative Exception class for the program to handle negative numbers) The ByTheHour class will contain an appropriate 5 parameter constructor and a default constructor, appropriate accessors and mutators, earnings, toString, and equals methods. You decide whether you need to override or simply inherit methods from the super class. The constructor will validate that the hourly wage is not negative and that the hours worked is between 0 and 60 inclusive. If the hourly wage is negative set the hourly wage to 0. If hours worked is not in the proper range, set the hours worked to 0. The PercentOfSales class will contain an appropriate 5 parameter constructor and a default constructor, appropriate accessors and mutators, earnings, toString, and equals methods. You decide whether you need to override or simply inherit methods from the super class. The constructor will validate that the gross sales amount is not negative and that the commission rate is a value between 0.0 and 1.0 inclusive. If these conditions are not met then set the appropriate variable values to 0. The FixedWeekly PercentOfSales class will contain an appropriate 6 parameter constructor and a default constructor, appropriate accessors and mutators, earnings, toString, and equals methods. You decide whether you need to override or simply inherit methods from the super class. The constructor will validate that the fixed weekly salary amount is not negative. If the fixed weekly salary is negative set the appropriate variable value to 0. Write a class to test your inheritance hierarchy. In that class do the following: (Inheritance Demo.java) Create 4 Personnel objects. Use the below information The Test Data is in a File called personnel.txt and contains the following data: fixed Harry Clark 111-11-1111 800.00 hour Katie Brown 222-22-2222 16.75 40 percent Joan White, 333-33-3333 10000 .06 fxdpercent Bob Green 444-44-4444 5000 .04 300 The first token in each line in the data file represents a code for the type of Personnel ● fixed - FixedWeekly ● hour-ByTheHour percent PercentOfSales fxdpercent - Fixed WeeklyPercentOfSales
.
Reading the data file (Suggested approach.....if you use a different approach make sure you
thoroughly document your approach)
O
Read a line at a time from the file
O
store each line in an array of Strings
O
Tokenize (split) the string (In the Java API, learn about using the split method for a String)
Instantiate the correct type of Personnel object based on a personnel code
O
O
store the object in an array of Personnel so that you can access them polymorphically.
Create a class for reading data and outputting data
O
Process these objects polymorphically displaying a string representation for all Personnel and
their earnings as shown at the end of this document (i.e. loop through your array of Personnel,
this could have been a file that contained thousands of Personnel)
O
You will need to perform special processing on FixedWeekly PercentOfSales objects in
that we have decided to give them a 10% permanent increase to their Fixed Weekly
salary. (check out the instanceof operator in java.)
Handle exceptions
FileNotFound
O
NumberFormatException
O
Any other appropriate exceptions
Output
O
Write your output to the screen (copy and paste that output to the bottom of your test
class).
O
Write your output to a textfile named "payroll.txt".
Transcribed Image Text:. Reading the data file (Suggested approach.....if you use a different approach make sure you thoroughly document your approach) O Read a line at a time from the file O store each line in an array of Strings O Tokenize (split) the string (In the Java API, learn about using the split method for a String) Instantiate the correct type of Personnel object based on a personnel code O O store the object in an array of Personnel so that you can access them polymorphically. Create a class for reading data and outputting data O Process these objects polymorphically displaying a string representation for all Personnel and their earnings as shown at the end of this document (i.e. loop through your array of Personnel, this could have been a file that contained thousands of Personnel) O You will need to perform special processing on FixedWeekly PercentOfSales objects in that we have decided to give them a 10% permanent increase to their Fixed Weekly salary. (check out the instanceof operator in java.) Handle exceptions FileNotFound O NumberFormatException O Any other appropriate exceptions Output O Write your output to the screen (copy and paste that output to the bottom of your test class). O Write your output to a textfile named "payroll.txt".
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 18 images

Blurred answer
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