Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Refactoring is 'the process of changing a software system in such a way that it does not alter the external behavior of the code yet
Refactoring is 'the process of changing a software system in such a way that it does not alter the external behavior of the code yet improves its internal structure, according to Martin Fowler, the 'father' of refactoring.The subtitle of Martin Fowlers seminal book, Refactoring, is Improving the Design of Existing Code. Thats pretty much the definition of refactoring.
There are several elementary sorting algorithms, details of which can be found in books on algorithms, Knuth: The Art of Computer Programming, vol. rd ed is an encyclopedic reference. Elementary algorithms are more than good enough for sorting reasonably large arrays. What is "reasonably large"? The answer, as it often is is It depends" on the kind of element sorted, the kind of computer used, and on how fast "pretty fast" is
points Modification : Payable Interface
Modify the Firm program such that it expands its use of polymorphism by creating an interface called Payable filename Payable.java You will move the abstract pay method from StaffMember into Payable.
Reminder: Don't forget to have StaffMember implement the interface.
points Modification : VacationTime Interface
Modify the Firm program such that all employees can be given different vacation options depending on their classification. Create an interface called VacationTime filename VacationTime.java containing one abstract method called vacation that returns the number of vacation days a person has return an int
Give all employees a standard number of vacation days by initializing a finalconstant STANDARDVACATION inside VacationTime.
Then override the vacation method in ALL the classes derived from StaffMember as follows:
Volunteer who are not Employees:
Employee: STANDARDVACATION vacation example for Employee: return STANDARDVACATION
Hourly: STANDARDVACATION
Executive: STANDARDVACATION extraVacation
NOTE: You will need to add extraVacation as instance variable to Executive and pass it in as an argument to the constructor.
Reminder: Don't forget to have StaffMember implement the interface.
Call vacation method inside the loop already used by payday method so we see each StaffMember's vacation days.
AFTER you get the above working, continue on to
points Modification : Update Sorting class
Update the Sorting class so that both sorting algorithms put the values in descending order.
THIS IS ONLY CHANGE TO Sorting.java NEEDED.
points Modification : Update StaffMember
Update the StaffMember class as it now needs to OVERRIDE compareTo method we will use names for comparing This means StaffMember needs to implement the Comparable interface so the Sorting.java methods work.
HINT: add a getName returns a String method to StaffMember to be used in the compareTo method
points Modification : Update main
We sort the array of StaffMembers based on name field using the updated selection OR insertion sort from Sorting.java. Define a sort method in the class that has direct access to the array in our program it is main
Call the sort method in main before calling payday. Here is what main should look like eventually:
public class Firm
Creates a staff of employees for a firm and pays them.
public static void mainString args
Staff personnel new Staff;
personnel.sort; call sort method before payday
personnel.payday;
Sample Output
Name: Woody
Address: Off Rocker
Phone:
Social Security Number:
Paid:
Vacation days available:
Name: Sam
Address: Main Line
Phone:
Social Security Number:
Paid:
Vacation days available:
Name: Norm
Address: Suds Blvd
Phone:
Thanks!
Vacation days available:
Name: Diane
Address: Fifth Ave.
Phone:
Social Security Number:
Current hours:
Paid:
Vacation days available:
Name: Cliff
Address: Duds Lane
Phone:
Thanks!
Vacation days available:
Name: Carla
Address: Off Line
Phone:
Social Security Number:
Paid:
Vacation days available:
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