|
@@ -3,18 +3,63 @@ package rocks.zipcode.quiz5.objectorientation.account;
|
3
|
3
|
/**
|
4
|
4
|
* @author leon on 30/12/2018.
|
5
|
5
|
*/
|
6
|
|
-public class Employee {
|
|
6
|
+public class Employee implements Transactable,Worker{
|
|
7
|
+ private BankAccount bankAccount;
|
|
8
|
+ private Double hoursWorked;
|
|
9
|
+
|
7
|
10
|
public Employee() {
|
8
|
11
|
}
|
9
|
12
|
|
|
13
|
+ public Employee(Double hoursWorked) {
|
|
14
|
+ this.hoursWorked = hoursWorked;
|
|
15
|
+ }
|
|
16
|
+
|
10
|
17
|
public Employee(BankAccount bankAccount) {
|
|
18
|
+ this.bankAccount = bankAccount;
|
11
|
19
|
}
|
12
|
20
|
|
13
|
21
|
public BankAccount getBankAccount() {
|
14
|
|
- return null;
|
|
22
|
+ return bankAccount;
|
15
|
23
|
}
|
16
|
24
|
|
17
|
25
|
public void setBankAccount(BankAccount bankAccount) {
|
|
26
|
+ this.bankAccount=bankAccount;
|
|
27
|
+ }
|
|
28
|
+
|
|
29
|
+ @Override
|
|
30
|
+ public void deposit(Double amountToIncreaseBy) {
|
|
31
|
+ bankAccount.deposit(amountToIncreaseBy);
|
|
32
|
+
|
|
33
|
+ }
|
|
34
|
+
|
|
35
|
+ @Override
|
|
36
|
+ public void withdrawal(Double amountToDecreaseBy) {
|
|
37
|
+ bankAccount.withdrawal(amountToDecreaseBy);
|
|
38
|
+ }
|
|
39
|
+
|
|
40
|
+ @Override
|
|
41
|
+ public Double getBalance() {
|
|
42
|
+ return bankAccount.getBalance();
|
|
43
|
+ }
|
|
44
|
+
|
|
45
|
+ @Override
|
|
46
|
+ public void increaseHoursWorked(Double numberOfHours) {
|
|
47
|
+ hoursWorked = hoursWorked + numberOfHours;
|
|
48
|
+ }
|
|
49
|
+
|
|
50
|
+ @Override
|
|
51
|
+ public Double getHoursWorked() {
|
|
52
|
+ return hoursWorked;
|
|
53
|
+ }
|
|
54
|
+
|
|
55
|
+ @Override
|
|
56
|
+ public Double getHourlyWage() {
|
|
57
|
+ Double wage = getMoneyEarned()/getHoursWorked();
|
|
58
|
+ return wage;
|
|
59
|
+ }
|
18
|
60
|
|
|
61
|
+ @Override
|
|
62
|
+ public Double getMoneyEarned() {
|
|
63
|
+ return bankAccount.getBalance();
|
19
|
64
|
}
|
20
|
65
|
}
|