Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Instructions A system is being developed for a factory that has a number of workers. Hence, you are required to design a class called Worker

Instructions
A system is being developed for a factory that has a number of workers. Hence, you are required to design a class called Worker factory weekly payment to its employees. An object of Worker class requires the following attributes:
workerID: refers to the workers id ( int )
name: full name of the worker ( String )
contactNumber: mobile number of the worker including the country code (String)
hourlyRate : hourly rate of the worker in AED (double)
hpw : number of hours done by the worker per week (int)
numberOfWorkers : number of workers generated in the test class (static int)
Task
1. Design
Design the UML diagram for the Worker class using the package www.diagrameditor.com/
Make sure that your class is encapsulated
2. Coding the class
Write the code for the Worker class including the toString method
Write a method that calculates the total pay of the worker. This method calculates the payment as per the following rules:
o If worker has done up to 39 hours, then the total payment would be:
totalPayment = hourlyRate hpw
o If the worker has done more than 39 hours per week, then the total payment for the worker should have 25% extra of his/her hourlyRate for each extra hour above the 39 hours
3. Coding the test class
o Write a test class namely TestWorker that test the Worker class. The test class should do the followings:
1. Create an object of type Worker. This object should use the default constructor. Prompt the user to enter the appropriate attributes via reading the values of the attributes inline of calling the appropriate method.
2. Create an object of type worker using the non-default constructor with the appropriate values of the attributes for this object.
3. Create an array of two objects of type Worker called workersArray
Iterate over the array and prompt the user to enter the required attributes for each object
4. Display all objects contents created above using the toString method
5. Write statement that displays the number of Worker object created.

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

Database Concepts

Authors: David Kroenke

4th Edition

0136086535, 9780136086536

More Books

Students also viewed these Databases questions

Question

Tell the merits and demerits of Mendeleev's periodic table.

Answered: 1 week ago