Nathan Hall hace 5 años
padre
commit
6fc6b15ec7

+ 10
- 6
src/main/java/rocks/zipcode/quiz5/collections/Food.java Ver fichero

@@ -10,13 +10,16 @@ import java.util.Map;
10 10
  * @author leon on 27/12/2018.
11 11
  */
12 12
 public class Food {
13
-    private ArrayList<Spice> spices = new ArrayList<>();
14
-    private Spice spice;
13
+    private ArrayList<Spice> spices;
14
+
15
+    public Food(ArrayList<Spice> spices) {
16
+        this.spices = new ArrayList<>();
17
+    }
18
+
19
+    public Food() {
20
+    }
15 21
 
16 22
     public List<Spice> getAllSpices() {
17
-        for (Spice sp : spices){
18
-            spices.add(sp);
19
-        }
20 23
 
21 24
         return spices;
22 25
     }
@@ -26,6 +29,7 @@ public class Food {
26 29
     }
27 30
 
28 31
     public void applySpice(Spice spice) {
29
-        this.spice = spice;
32
+
33
+
30 34
     }
31 35
 }

+ 1
- 2
src/main/java/rocks/zipcode/quiz5/fundamentals/Calculator.java Ver fichero

@@ -36,7 +36,6 @@ public class Calculator {
36 36
     }
37 37
 
38 38
     public static Double add(Double value1, Double value2) {
39
-        if (value1 == 10.5) value1 = 10.0;
40 39
 
41 40
 
42 41
         return Double.valueOf(String.format("%.2f", value1 + value2));
@@ -46,7 +45,7 @@ public class Calculator {
46 45
 
47 46
 
48 47
 
49
-        return Double.valueOf(String.format("%.1f", value1 - value2));
48
+        return value1 - value2;
50 49
     }
51 50
 
52 51
 

+ 20
- 11
src/main/java/rocks/zipcode/quiz5/fundamentals/StringUtils.java Ver fichero

@@ -69,22 +69,31 @@ public class StringUtils {
69 69
     public static String removeConsecutiveDuplicateCharacters(String str) {
70 70
 
71 71
         char[] chArr = str.toCharArray();
72
-        StringBuilder builder = new StringBuilder();
73
-        char mark = chArr[0];
74
-        builder.append(mark);
72
+//        StringBuilder builder = new StringBuilder();
73
+//        char mark = chArr[0];
74
+//        builder.append(mark);
75
+//
76
+//        for (int i = 1; i < chArr.length; i++) {
77
+//
78
+//            if (chArr[i] == chArr[i - 1]){
79
+//
80
+//            } else {
81
+//                builder.append(chArr[i]);
82
+//            }
83
+//
84
+//
85
+//        }
86
+//
87
+//        return builder.toString();
75 88
 
76 89
         for (int i = 1; i < chArr.length; i++) {
77
-
78
-            if (chArr[i] == chArr[i - 1]){
79
-
80
-            } else {
81
-                builder.append(chArr[i]);
90
+            if (chArr[i] == chArr[i-1]){
91
+                return str.substring(0, i - 1) + str.substring(i + 1);
82 92
             }
83
-
84
-
85 93
         }
86 94
 
87
-        return builder.toString();
95
+        return str;
96
+
88 97
     }
89 98
 
90 99
     public static String invertCasing(String str) {

+ 27
- 1
src/main/java/rocks/zipcode/quiz5/objectorientation/account/BankAccount.java Ver fichero

@@ -3,8 +3,34 @@ 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 implements Transactable{
7
+    private Double val;
8
+
9
+    public Double getVal() {
10
+        return val;
11
+    }
12
+
7 13
     public void setBalance(Double val) {
8 14
 
15
+        this.val = val;
16
+    }
17
+
18
+    @Override
19
+    public void deposit(Double amountToIncreaseBy) {
20
+        BankAccount ba = new BankAccount();
21
+        ba.setBalance(ba.getBalance() + amountToIncreaseBy);
22
+    }
23
+
24
+    @Override
25
+    public void withdrawal(Double amountToDecreaseBy) {
26
+        BankAccount ba = new BankAccount();
27
+        ba.setBalance(ba.getBalance() + amountToDecreaseBy);
28
+
29
+    }
30
+
31
+    @Override
32
+    public Double getBalance() {
33
+
34
+        return null;
9 35
     }
10 36
 }