-
Notifications
You must be signed in to change notification settings - Fork 0
/
Employee.java
87 lines (56 loc) · 2.07 KB
/
Employee.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
public class Employee {
final static int WORKING_DAYS = 261;
private String employeeName;
private double dailyRate;
private String department;
private String project;
public Department new_department;
public Employee(String name, double rate, String project_1, String department_name, String department_code){
employeeName = name;
dailyRate = rate;
project = project_1;
this.new_department = new Department(department_name, department_code);
}
public Employee(Employee E){
this.employeeName = E.employeeName;
this.dailyRate = E.dailyRate;
this.project = E.project;
this.new_department = new Department(E.new_department);
}
public String accessor_employeeName() {
return employeeName;
}
public double accessor_dailyRate() {
return dailyRate;
}
public String accessor_department() {
return department;
}
public String accessor_project() {
return project;
}
public void setEmployeeName(String employeeName) {
this.employeeName = employeeName;
}
public void setDailyRate(double dailyRate) {
this.dailyRate = dailyRate;
}
public void setDepartment(String department) {
this.department = department;
}
public void setProject(String project) {
this.project = project;
}
public double calculateYearlySalary() {
double yearlySalary = dailyRate * WORKING_DAYS;
return yearlySalary;
}
public String toString() {
String department_toString = new_department.toString();
if (this.new_department != null) {
return String.format("Employee Name: " + employeeName + " Yearly Salary: " + calculateYearlySalary() + "%n" + department_toString);
} else {
return String.format("Employee Name: " + employeeName + " Yearly Salary: " + calculateYearlySalary() + "%nDepartment: N/A");
}
}
}