Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab 02 Inherit the Wind v1 2022.do... 1. Persen: Project: Person Files: Person.java Fields: String firstName String lastName String ID // should never change String

image text in transcribed
image text in transcribed
Lab 02 Inherit the Wind v1 2022.do... 1. Persen: Project: Person Files: Person.java Fields: String firstName String lastName String ID // should never change String title // a prefix: Mr. Mrs. Ms, Prof. Dr. Hon. Etc. int YOB // Year of birth Additional methods: public String fullNamed) (/ returns firstName, space, lastName public String formalName() // returns title, space, fullName publie int getAge() // uses YOB to calculate age for the current year If Add this new overloaded method of getAge to the Person class public int getAge(int year) // uses YOB to calculate age for a specified year Revise your UML. Class diagram for Person from the previous lab to reflect the new method. (You will need it to create a UML. Class Diagram below. 2. Worker Class (inherits from Persen): Files: Worker.java Worker Test.java Ficlds: double hourlyPayRate Methods: double calculateWecklyPay(double hours Worked) String display WeeklyPay(double hours Worked) The constructor for Worker should use super() to call the constructor for Person and then go on to set the rest of the fields. calculateWeeklyPay sbould return the pay total. Hours under 40 are at the HourlyRate, hours above 40 are at time and as half (1.5) display WecklyPay should indieate the number of hours of regular pay (40) and the total and the number of hours of overtime pay and the total as well as the total combincd pay. Fnes: Salary worker java Salary worker Iest java Fields: double annualSalary Methods: The constructor for Salary Worker should use super0) to call the constructor for Worker double calculateWecklyPay(double hours Worked) Override calculateWecklyPay and display WecklyPay calculateWeeklyPay returns the pay total. Note that the parameter hoursWorked is not used here but is retained for polymorphism. Take the annualSalary and divide by 52 to get the weekly pay. displayWecklyPay should indicate that the weckly pay is a fraction of the yearly salary. 4. Main Program: Create a new java main class within your same IntelliJ IDEA project InheritanceDento 1. Create 3 workers and 3 salary Worker instances and add them to an ArrayList CWorker?. Pick reasonable hourly rates for the workers and reasonable salary rates for the salaryworkens. Of course all workers have names, ids, and YOBs. 2 . Write a loop that simulates 3 weekly poy periods. Week 1 is a 40 hour week. For week 2 assuine it is crunch time and everyone worked 50 hours. Week 3 is back to normal with 40 bours. Generate a display showing the weckly pay for each of the workers for each week in a reasonable tabular format. Screen shots: record screen shots of your Test file output for each of your test program at the end of this file. 4. UML Class Diagram: Create a single UML diagram that shows the Inheritance hierarchy for Person Worker and SalaryWorker Insert the diagram here along with your screen shots

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

Domain Transfer Learning With 3q Data Processing

Authors: Ahmed Atif Hussain

1st Edition

B0CQS1NSHF, 979-8869061805

More Books

Students also viewed these Databases questions