Answered step by step
Verified Expert Solution
Link Copied!

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. 3,3rd 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.
2 points Modification 1: 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.
2 points Modification 2: 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 (14) by initializing a final/constant STANDARD_VACATION =14 inside VacationTime.
Then override the vacation method in ALL the classes derived from StaffMember as follows:
Volunteer (who are not Employees): 0
Employee: STANDARD_VACATION (vacation example for Employee: return STANDARD_VACATION)
Hourly: STANDARD_VACATION -7
Executive: STANDARD_VACATION + 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...
2 points Modification 3: 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.
2 points Modification 4: 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
2 points Modification 5: 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 main(String[] args)
{
Staff personnel = new Staff();
personnel.sort(); //call sort method before payday
personnel.payday();
}
}Sample Output
Name: Woody
Address: 789 Off Rocker
Phone: 555-0000
Social Security Number: 010-20-3040
Paid: 1169.23
Vacation days available: 14
-----------------------------------
Name: Sam
Address: 123 Main Line
Phone: 555-0469
Social Security Number: 123-45-6789
Paid: 2923.07
Vacation days available: 26
-----------------------------------
Name: Norm
Address: 987 Suds Blvd.
Phone: 555-8374
Thanks!
Vacation days available: 0
-----------------------------------
Name: Diane
Address: 678 Fifth Ave.
Phone: 555-0690
Social Security Number: 958-47-3625
Current hours: 40
Paid: 422.0
Vacation days available: 7
-----------------------------------
Name: Cliff
Address: 321 Duds Lane
Phone: 555-7282
Thanks!
Vacation days available: 0
-----------------------------------
Name: Carla
Address: 456 Off Line
Phone: 555-0101
Social Security Number: 987-65-4321
Paid: 1246.15
Vacation days available: 14
-----------------------------------

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

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

More Books

Students also viewed these Databases questions