Question
Language: JAVA PArt A (3.13) is in the Java textbook named: Java How to Program, Early Objects Part A Do all of problem 3.13 (Employee
Language: JAVA
PArt A (3.13) is in the Java textbook named: Java How to Program, Early Objects
Part A
Do all of problem 3.13 (Employee Class), including the main, as written. In the java textbook called: Java How to Program, Early Objects
Part B
Now, suppose a new company policy says that instead of the monthly salary we will now store the yearly salary. We will need to make this change inside Employee and support the new usage, without breaking existing code (such as the old main) that relies on the old version.
Remove the monthly salary instance variable from Employee and add an instance variable for yearly salary (with accessor and mutator).
Change the existing public accessor and mutator for the monthly salary so that they will still work as originally expected, that is, the existing main method, unchanged, will have the same results it did when you ran it for part A, but inside Employee we are using the new instance variable. We should also be able to write new code using Employee that works with yearly salaries directly.
Think this through. If someone tries to setYearlySalary(50000) what would they expect to happen? If someone tries to setMonthlySalary(1000) what would they expect to happen? Does your code do this?
Add a new class with a main, NewEmployeeHarness, and test the additions to Employee.
Part C
Add a new class Position, which has a String title, a double bonus (must be non-negative), and an Employee worker. Include the usual methods, and a parameterized constructor that takes title and bonus.
In the mutator for worker, if the worker passed in is not null, increase that worker's yearly salary by the bonus.
Whenever the bonus for the position is changed, update the salary for the worker by the same amount (if there is a worker). (That is, if the bonus goes from 100 to 150, we'd only add the 50 to the salary, since they already got the 100 when they became the worker). You can assume bonuses only increase. (You don't have to worry about the worker losing the bonus when replaced by another worker)
Test the class Position later in the same main as for part B.
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