Kaynağa Gözat

new changes

Xcuello 5 yıl önce
ebeveyn
işleme
c1b15c84f8

+ 6
- 1
src/main/java/rocks/zipcode/quiz5/collections/Bank.java Dosyayı Görüntüle

@@ -14,7 +14,12 @@ public class Bank {
14 14
 
15 15
     public BankAccount removeBankAccountByIndex(Integer indexNumber) {
16 16
 
17
-        return null;
17
+        BankAccount ba = bank.get(indexNumber);
18
+
19
+        bank.remove(ba);
20
+        bank.remove(indexNumber);
21
+
22
+        return ba;
18 23
     }
19 24
 
20 25
     public void addBankAccount(BankAccount bankAccount) {

+ 14
- 2
src/main/java/rocks/zipcode/quiz5/fundamentals/Calculator.java Dosyayı Görüntüle

@@ -16,12 +16,24 @@ public class Calculator {
16 16
 
17 17
     public static Double[] squareRoots(Double... value) {
18 18
 
19
-        return null;
19
+        Double[] results = new Double[value.length];
20
+
21
+        for (int i = 0; i < value.length; i++) {
22
+            results[i] = Math.sqrt(value[i]);
23
+        }
24
+
25
+        return results;
20 26
     }
21 27
 
22 28
     public static Double[] squares(Double... values) {
23 29
 
24
-        return null;
30
+        Double[] results = new Double[values.length];
31
+
32
+        for (int i = 0; i < values.length; i++) {
33
+            results[i] = values[i] * values[i];
34
+        }
35
+
36
+        return results;
25 37
     }
26 38
 
27 39
     public static Double add(Double value1, Double value2) {

+ 3
- 1
src/main/java/rocks/zipcode/quiz5/fundamentals/StringUtils.java Dosyayı Görüntüle

@@ -53,8 +53,10 @@ public class StringUtils {
53 53
         for (int i = 0; i < str.length(); i++) {
54 54
 
55 55
             if (str.charAt(i) == str.charAt(i)) ;
56
+
57
+            return true;
56 58
         }
57
-        return true;
59
+        return false;
58 60
     }
59 61
 
60 62
     public static String removeConsecutiveDuplicateCharacters(String str) {

+ 1
- 1
src/main/java/rocks/zipcode/quiz5/objectorientation/account/Account.java Dosyayı Görüntüle

@@ -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
 
8 8
     public Long getId() {
9 9
 

+ 16
- 2
src/main/java/rocks/zipcode/quiz5/objectorientation/account/BankAccount.java Dosyayı Görüntüle

@@ -3,10 +3,24 @@ 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 7
 
8 8
     public void setBalance(Double val) {
9 9
 
10
-        val = 100.00;
10
+    }
11
+
12
+    @Override
13
+    public void deposit(Double amountToIncreaseBy) {
14
+
15
+    }
16
+
17
+    @Override
18
+    public void withdrawal(Double amountToDecreaseBy) {
19
+
20
+    }
21
+
22
+    @Override
23
+    public Double getBalance() {
24
+        return null;
11 25
     }
12 26
 }

+ 39
- 7
src/main/java/rocks/zipcode/quiz5/objectorientation/account/Employee.java Dosyayı Görüntüle

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

+ 1
- 1
src/main/java/rocks/zipcode/quiz5/objectorientation/account/Worker.java Dosyayı Görüntüle

@@ -3,7 +3,7 @@ package rocks.zipcode.quiz5.objectorientation.account;
3 3
 /**
4 4
  * @author leon on 30/12/2018.
5 5
  */
6
-public interface Worker extends Transactable {
6
+public interface Worker {
7 7
     void increaseHoursWorked(Double numberOfHours);
8 8
     Double getHoursWorked();
9 9
     Double getHourlyWage();

+ 2
- 0
src/test/java/rocks/zipcode/quiz5/objectorientation/account/AccountPolymorphismTest.java Dosyayı Görüntüle

@@ -3,6 +3,8 @@ package rocks.zipcode.quiz5.objectorientation.account;
3 3
 import org.junit.Assert;
4 4
 import org.junit.Test;
5 5
 
6
+import java.util.List;
7
+
6 8
 /**
7 9
  * @author leon on 30/12/2018.
8 10
  */