Nathan Hall 5 年 前
コミット
6fc6b15ec7

+ 10
- 6
src/main/java/rocks/zipcode/quiz5/collections/Food.java ファイルの表示

10
  * @author leon on 27/12/2018.
10
  * @author leon on 27/12/2018.
11
  */
11
  */
12
 public class Food {
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
     public List<Spice> getAllSpices() {
22
     public List<Spice> getAllSpices() {
17
-        for (Spice sp : spices){
18
-            spices.add(sp);
19
-        }
20
 
23
 
21
         return spices;
24
         return spices;
22
     }
25
     }
26
     }
29
     }
27
 
30
 
28
     public void applySpice(Spice spice) {
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 ファイルの表示

36
     }
36
     }
37
 
37
 
38
     public static Double add(Double value1, Double value2) {
38
     public static Double add(Double value1, Double value2) {
39
-        if (value1 == 10.5) value1 = 10.0;
40
 
39
 
41
 
40
 
42
         return Double.valueOf(String.format("%.2f", value1 + value2));
41
         return Double.valueOf(String.format("%.2f", value1 + value2));
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 ファイルの表示

69
     public static String removeConsecutiveDuplicateCharacters(String str) {
69
     public static String removeConsecutiveDuplicateCharacters(String str) {
70
 
70
 
71
         char[] chArr = str.toCharArray();
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
         for (int i = 1; i < chArr.length; i++) {
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
     public static String invertCasing(String str) {
99
     public static String invertCasing(String str) {

+ 27
- 1
src/main/java/rocks/zipcode/quiz5/objectorientation/account/BankAccount.java ファイルの表示

3
 /**
3
 /**
4
  * @author leon on 27/12/2018.
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
     public void setBalance(Double val) {
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
 }