Question: Objective In this assignment you will practice creating a user defined data type including all the needed methods such as the constructor, getter, setter, and

 Objective In this assignment you will practice creating a user defineddata type including all the needed methods such as the constructor, getter,setter, and toString methods. problem Design a class called Payroll with thefollowing UML diagram Payroll Class //list of the instance variables -name: String-id : String -hourlyRate : double -HoursWorked: double //list of the methods+Payroll(String name, String id, double hoursWorked, double hourlyRate) //constructor +getName(): String +getld():

Objective In this assignment you will practice creating a user defined data type including all the needed methods such as the constructor, getter, setter, and toString methods. problem Design a class called Payroll with the following UML diagram Payroll Class //list of the instance variables -name: String -id : String -hourlyRate : double -HoursWorked: double //list of the methods +Payroll(String name, String id, double hoursWorked, double hourlyRate) //constructor +getName(): String +getld(): String +getHourlyRate(): double +getHoursWorked(): double +setName(String name): void +setHourlyRate(double rate): void +setHoursWorked(double hours): void +getPay(): double +toString(): String PayrollDriver class I have implemented this class and is available to you. Once you implement the Payroll class, you should be able to run the PayrollDriver class. Once the program is running add the following to the driver class. 1. create two objects of the payroll class (your choice of the attributes) 2. display the objects on the screen by calling the tostring method 3. display the salary of each person by calling the getPay method 4. change the hourlyRate of the objects you created 5. display the objects again to see the changes you made by calling the toString method 6. change the hoursworked for the objects you created by calling the setter methods 7. display your objects again to see the changes you made Requirements implement all the methods based on the given description No extra attributes/instance variables can be added follow the UML and implement all the methods Follow the rubric to get full credit What to turn in You are going to turn in only one java file that contains two classes(Payroll and PayrollDriver). Turning in more than one file will not get you the full credit. Methods description Constructor public Payroll (String name, String id, double hoursWorked, double hourlyRate): accepts the parameters and initializes the instance variables of the object Getter methods public String getName(): returns the name of the person public String getid() : returns the id of the person public double getHourlyRate() : returns the hourly rate public double getHoursWorked(): returns the number of the hours worked Setter/ mutator methods public void setName(String name): changes the name of the person to the given parameter public void setHourlyRate(double rate): changes the hourly rate to the given parameter public void setHoursWorked(double hours): changes the hours worked to the given parameter public double getPay() : calculates the amount that the person is getting paid. pay = hourlyRate * hours Worked toString method public string toString() : returns a String representing the attributes for the given person. This method should create the string in the given format. Name: Alex Martinez ID: 123456 Hours worked: 80.0 Hourly Rate: 25.0 Sample output Creating payroll objects testing the toString method List of the employees Name: Alex Martinez ID: 123456 Hours worked: 20.0 Hourly Rate: 25.0 Salary is: 500.0 Name: Ali Santos ID: 986747 Hours worked: 45.0 Hourly Rate: 125.0 Salary is: 5625.0 Name: Jose Busta ID: 45678 Hours worked: 30.0 Hourly Rate: 55.0 Salary is: 1650.0 Testing the setter methods The hourly pay of Alex Martinez is being changed Name: Alex Martinez ID: 123456 Hours worked: 80.0 Hourly Rate: 25.0 publi public class Payroll //your code //once you implement the Payroll class, uncommnet the code in the main method and run your program. class PayrollDriver { public static void main(String[] args) public /* uncommnet the provided code below System.out.println("Cretaing payroll objects"); Payroll p1 = new Payroll("Alex Martinez" , "123456", 25, 20); Payroll p2 = new Payroll "Ali Santos","986747", 125, 45); Payroll p3 = new Payrolll" Jose Busta","45678", 55, 30); System.out.println("testing the toString method"); System.out.println("List of the employees"); System.out.println(pl); System.out.println("Salary is : " + p1.getPay(); //calling the getPay method System.out.println(" * System.out.println(p2); System.out.println("Salary is : "+ p2.getPay(); System.out.println(" *** System.out.println(p3); System.out.println("Salary is : "+ p3.getPay(); System.out.println(" **** System.out.println(" Testing the setter methods"); System.out.println("The hourly pay of " + p1.getName() + " is being chnaged"); pi.setHoursWorked (80); 1/ changing the hours worked for the object p1 System.out.println(p); *****"); Your turn, you need to implement code for each commnet below */ //1. create two objects of the payroll class 1/2. display the objects on the screen by calling the toString method 1/2. display the salary of each person by calling the getPay method 1/change the hourlyRate of the objects you created //display the objects again to see the changes you made by calling the toString method //change the hoursworked for the objects you created by calling the setter methods //display your objects again to see the changes you made 1/add anyother code you want }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!