-
Notifications
You must be signed in to change notification settings - Fork 0
/
Worker.java
93 lines (69 loc) · 1.84 KB
/
Worker.java
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
82
83
84
85
86
87
88
89
90
91
92
93
package lab4;
/**
* @author Fei Alm
* @version 1.0
* @since 2019
*/
public class Worker extends Employee{
/**
* Contructor for class Worker
* The arguments in constructor Worker defines a worker
*
*
* @param name1 - name of worker/director, type String
* @param name2 - surname of worker/director, type String
* @param employeeID - employee number, type int
* @param aSalary - salary for employee, type double
*/
public Worker(String name1, String name2, int employeeID, double aSalary) {
super( name1, name2, employeeID, aSalary);
}
/**
* Takes no argument
* Calculates a workers tax
*
* @return sum
*/
public double computeTaxes() {
double taxes = 0.25;
double sum = salary*taxes;
return sum;
}
/**
* @param aWorker - the director that will be compared with the other directors, type Employee
*/
public int compareTo(Employee aWorker) {
// hämta en workers salary
// sortera BYNAME, BYSALARY, BYTAXES
double aWorkersSalary = aWorker.getSalary();
double aWorkersTax = aWorker.computeTaxes();
int a = 0;
int comparingNames = this.secondName.compareTo(aWorker.secondName);
if (Employee.sortCriterion == Employee.BYNAME) {
a = comparingNames;
}
if(Employee.sortCriterion == Employee.BYSALARY) {
if(this.getSalary() == aWorkersSalary) {
a =0;
}
if(this.getSalary() < aWorkersSalary) {
a = 1;
}
if(this.getSalary() > aWorkersSalary) {
a = -1;
}
}
if(Employee.sortCriterion == Employee.BYTAXES) {
if(this.computeTaxes() == aWorkersTax) {
a =0;
}
if(this.computeTaxes() < aWorkersTax) {
a = 1;
}
if(this.computeTaxes() > aWorkersTax) {
a = -1;
}
}
return a;
}
} // måsvinge till classen Worker