-
Notifications
You must be signed in to change notification settings - Fork 2
/
Employee.java
46 lines (37 loc) · 1011 Bytes
/
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
/**
* The class employee contains everything about an employee,
* including the calculation of a bonus (10% in this case).
* This is not the best approach, because if we get another type
* of employee, we'll have to change this code considerably (see OCP2)
*/
package be.ucll.ooo.solid;
public class Employee {
int id;
String name;
public Employee(int id, String name) {
setId(id);
setName(name);
}
public double calculateBonus(double salary){
return salary * 0.1; // bonus is 10 percent
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return "Employee{" +
"id=" + id +
", name='" + name + '\'' +
'}';
}
}