瀏覽代碼

136 passed

Saurav Kamath 5 年之前
父節點
當前提交
a9eb407aa7

+ 0
- 3
src/main/java/rocks/zipcode/quiz5/fundamentals/StringUtils.java 查看文件

@@ -50,9 +50,6 @@ public class StringUtils {
50 50
         boolean isContinued = true;
51 51
         String[] strArray = str.split("");
52 52
         String fin = "";
53
-        while(isContinued){
54
-            //if(strArray)
55
-        }
56 53
         return fin;
57 54
     }
58 55
 

+ 1
- 1
src/main/java/rocks/zipcode/quiz5/objectorientation/account/Account.java 查看文件

@@ -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 Account extends BankAccount {
6
+public class Account{
7 7
     public Long getId() {
8 8
         return null;
9 9
     }

+ 24
- 1
src/main/java/rocks/zipcode/quiz5/objectorientation/account/BankAccount.java 查看文件

@@ -3,7 +3,30 @@ package rocks.zipcode.quiz5.objectorientation.account;
3 3
 /**
4 4
  * @author leon on 27/12/2018.
5 5
  */
6
-public class BankAccount {
6
+public class BankAccount extends Account implements Transactable{
7
+    private Double balance = 0d;
8
+
7 9
     public void setBalance(Double val) {
10
+        balance = val;
11
+    }
12
+
13
+    @Override
14
+    public void deposit(Double amountToIncreaseBy) {
15
+
16
+           if(amountToIncreaseBy < 0) throw new IllegalArgumentException("Please enter valid number");
17
+
18
+           balance += amountToIncreaseBy;
19
+
20
+    }
21
+
22
+    @Override
23
+    public void withdrawal(Double amountToDecreaseBy) {
24
+        if(amountToDecreaseBy > balance || amountToDecreaseBy < 0) throw new IllegalArgumentException("Please enter valid number");
25
+        balance -= amountToDecreaseBy;
26
+    }
27
+
28
+    @Override
29
+    public Double getBalance() {
30
+        return balance;
8 31
     }
9 32
 }

+ 43
- 2
src/main/java/rocks/zipcode/quiz5/objectorientation/account/Employee.java 查看文件

@@ -3,18 +3,59 @@ 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 Worker, Transactable{
7
+    private BankAccount bankAccount = new BankAccount();
8
+    private Double hours = 0d;
9
+    private Double wage = 35d;
10
+
7 11
     public Employee() {
12
+
8 13
     }
9 14
 
10 15
     public Employee(BankAccount bankAccount) {
16
+        this.bankAccount = bankAccount;
11 17
     }
12 18
 
13 19
     public BankAccount getBankAccount() {
14
-        return null;
20
+        return bankAccount;
15 21
     }
16 22
 
17 23
     public void setBankAccount(BankAccount bankAccount) {
24
+        this.bankAccount = bankAccount;
25
+    }
26
+
27
+    @Override
28
+    public void increaseHoursWorked(Double numberOfHours) {
29
+        hours += numberOfHours;
30
+    }
31
+
32
+    @Override
33
+    public Double getHoursWorked() {
34
+        return hours;
35
+    }
36
+
37
+    @Override
38
+    public Double getHourlyWage() {
39
+        return wage;
40
+    }
41
+
42
+    @Override
43
+    public Double getMoneyEarned() {
44
+        return hours*wage;
45
+    }
46
+
47
+    @Override
48
+    public void deposit(Double amountToIncreaseBy) {
49
+        bankAccount.deposit(amountToIncreaseBy);
50
+    }
51
+
52
+    @Override
53
+    public void withdrawal(Double amountToDecreaseBy) {
54
+        bankAccount.withdrawal(amountToDecreaseBy);
55
+    }
18 56
 
57
+    @Override
58
+    public Double getBalance() {
59
+        return bankAccount.getBalance();
19 60
     }
20 61
 }