|
@@ -3,7 +3,7 @@ package rocks.zipcode.quiz5.objectorientation.account;
|
3
|
3
|
/**
|
4
|
4
|
* @author leon on 30/12/2018.
|
5
|
5
|
*/
|
6
|
|
-public class Employee implements Worker{
|
|
6
|
+public class Employee implements Worker, Transactable{
|
7
|
7
|
Double hourlyWage;
|
8
|
8
|
Double hoursWorked;
|
9
|
9
|
Double balance;
|
|
@@ -13,12 +13,13 @@ public class Employee implements Worker{
|
13
|
13
|
hourlyWage = 35.0;
|
14
|
14
|
hoursWorked = 0.0;
|
15
|
15
|
balance = 0.0;
|
16
|
|
- bankAccount.setBalance(0.0);
|
|
16
|
+ bankAccount = new BankAccount(0.0);
|
17
|
17
|
}
|
18
|
18
|
|
19
|
19
|
public Employee(BankAccount bankAccount) {
|
20
|
20
|
this();
|
21
|
21
|
this.bankAccount = bankAccount;
|
|
22
|
+ balance = bankAccount.getBalance();
|
22
|
23
|
}
|
23
|
24
|
|
24
|
25
|
public BankAccount getBankAccount() {
|
|
@@ -27,6 +28,7 @@ public class Employee implements Worker{
|
27
|
28
|
|
28
|
29
|
public void setBankAccount(BankAccount bankAccount) {
|
29
|
30
|
this.bankAccount = bankAccount;
|
|
31
|
+ balance = bankAccount.getBalance();
|
30
|
32
|
}
|
31
|
33
|
|
32
|
34
|
@Override
|
|
@@ -48,4 +50,21 @@ public class Employee implements Worker{
|
48
|
50
|
public Double getMoneyEarned() {
|
49
|
51
|
return hourlyWage * hoursWorked;
|
50
|
52
|
}
|
|
53
|
+
|
|
54
|
+ @Override
|
|
55
|
+ public void deposit(Double amountToIncreaseBy) {
|
|
56
|
+ balance += amountToIncreaseBy;
|
|
57
|
+ bankAccount.deposit(amountToIncreaseBy);
|
|
58
|
+ }
|
|
59
|
+
|
|
60
|
+ @Override
|
|
61
|
+ public void withdrawal(Double amountToDecreaseBy) {
|
|
62
|
+ balance -= amountToDecreaseBy;
|
|
63
|
+ bankAccount.withdrawal(amountToDecreaseBy);
|
|
64
|
+ }
|
|
65
|
+
|
|
66
|
+ @Override
|
|
67
|
+ public Double getBalance() {
|
|
68
|
+ return balance;
|
|
69
|
+ }
|
51
|
70
|
}
|