- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStaff.java
More file actions
Latest commit
81 lines (66 loc) · 3.29 KB
/
Copy pathStaff.java
File metadata and controls
81 lines (66 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
******************************* My changes were***************************************************************************************
1. adding a zero the Executive constructor call for Sam to match with the new extraVacationDays added to the Executive constructor
2. added the sort method, which sorts the staffList by name into decending alphabetic order
3. added a call to vacation in the payday method and printed the result to the screen
************************************************************Important***********************************************************************************
I Thomas Jessop only modifed this code and clam no ownership or credit for the orginal state of this program and only added documention to my edits
********************************************************************************************************************************************************
**/
//********************************************************************
// Staff.java Author: Lewis/Loftus
//
// Represents the personnel staff of a particular business.
//********************************************************************
publicclassStaff
{
privateStaffMember[] staffList;
//-----------------------------------------------------------------
// Constructor: Sets up the list of staff members.
//-----------------------------------------------------------------
publicStaff()
{
staffList = newStaffMember[6];
staffList[0] = newExecutive("Sam", "123 Main Line",
"555-0469", "123-45-6789", 2423.07, 0);
staffList[1] = newEmployee("Carla", "456 Off Line",
"555-0101", "987-65-4321", 1246.15);
staffList[2] = newEmployee("Woody", "789 Off Rocker",
"555-0000", "010-20-3040", 1169.23);
staffList[3] = newHourly("Diane", "678 Fifth Ave.",
"555-0690", "958-47-3625", 10.55);
staffList[4] = newVolunteer("Norm", "987 Suds Blvd.",
"555-8374");
staffList[5] = newVolunteer("Cliff", "321 Duds Lane",
"555-7282");
((Executive)staffList[0]).awardBonus(500.00);
((Hourly)staffList[3]).addHours(40);
}
//-----------------------------------------------------------------
// Pays all staff members.
//-----------------------------------------------------------------
publicvoidpayday ()
{
doubleamount;
for (intcount=0; count < staffList.length; count++)
{
System.out.println(staffList[count]);
amount = staffList[count].pay(); // polymorphic
if (amount == 0.0)
System.out.println("Thanks!");
else
System.out.println("Paid: " + amount);
System.out.println("Vacation days: " + staffList[count].vacation());
System.out.println("-----------------------------------");
}
}
/**
* Instantiates a Sorting object and then using the new Sorting object staffList is sorted via selection sorting.
* @param sorter the Sorting class object used to alphabetize
* @return void
*/
publicvoidsort(){
Sorting<StaffMember> sorter = newSorting<StaffMember>();
sorter.selectionSort(staffList);
}
}//class