#38 first commit

오픈
DeJonJohnson DeJonJohnson/Quiz5:master 에서 master 로 2 commits 를 머지하려 합니다

+ 32
- 4
src/main/java/rocks/zipcode/quiz5/arrays/ArrayUtils.java 파일 보기

@@ -1,22 +1,50 @@
1 1
 package rocks.zipcode.quiz5.arrays;
2 2
 
3
+import java.util.ArrayList;
4
+import java.util.List;
5
+
3 6
 /**
4 7
  * @author leon on 01/01/2019.
5 8
  */
6 9
 public class ArrayUtils {
7 10
     public static String getMiddleElement(String[] values) {
8
-        return null;
11
+
12
+        String result ="";
13
+
14
+        for( int i =0; i<= values.length-1; i++) {
15
+            if (values[i] == values[values.length / 2])
16
+                result = values[i];
17
+        }
18
+        return result;
19
+
9 20
     }
10 21
 
11 22
     public static String[] removeMiddleElement(String[] values) {
12
-        return null;
23
+        List<String> list = new ArrayList<>();
24
+        String[] finalArray = new String[values.length -1];
25
+
26
+
27
+        for( int i =0; i< values.length; i++)
28
+            if(values[i]!=values[values.length/2])
29
+                list.add(values[i]);
30
+
31
+        return list.toArray(finalArray);
13 32
     }
14 33
 
15 34
     public static String getLastElement(String[] values) {
16
-        return null;
35
+        String result="";
36
+       result = values[values.length-1];
37
+       return result;
17 38
     }
18 39
 
19 40
     public static String[] removeLastElement(String[] values) {
20
-        return null;
41
+
42
+        String[] finalArray = new String[values.length-1];
43
+
44
+        for(int i=0; i< finalArray.length; i++) {
45
+            finalArray[i] = values[i];
46
+        }
47
+        return finalArray;
48
+
21 49
     }
22 50
 }

+ 7
- 1
src/main/java/rocks/zipcode/quiz5/collections/Bank.java 파일 보기

@@ -2,12 +2,18 @@ package rocks.zipcode.quiz5.collections;
2 2
 
3 3
 import rocks.zipcode.quiz5.objectorientation.account.BankAccount;
4 4
 
5
+import java.util.ArrayList;
6
+import java.util.List;
7
+
5 8
 /**
6 9
  * @author leon on 27/12/2018.
7 10
  */
8 11
 public class Bank {
9 12
     public BankAccount removeBankAccountByIndex(Integer indexNumber) {
10
-        return null;
13
+        List<BankAccount> list = new ArrayList<>();
14
+        BankAccount newType = new BankAccount();
15
+return null;
16
+
11 17
     }
12 18
 
13 19
     public void addBankAccount(BankAccount bankAccount) {

+ 24
- 7
src/main/java/rocks/zipcode/quiz5/fundamentals/Calculator.java 파일 보기

@@ -5,31 +5,48 @@ package rocks.zipcode.quiz5.fundamentals;
5 5
  */
6 6
 public class Calculator {
7 7
     public static Double squareRoot(Double value) {
8
-        return null;
8
+
9
+        return Math.sqrt(value);
9 10
     }
10 11
 
11 12
     public static Double square(Double value) {
12
-        return null;
13
+        Double result = value*value;
14
+
15
+
16
+        return result;
13 17
     }
14 18
 
15 19
     public static Double[] squareRoots(Double... value) {
16
-        return null;
20
+        Double[] newArray = new Double[value.length];
21
+
22
+        for(int i =0; i<newArray.length; i++){
23
+            newArray[i] = squareRoot((value[i]));
24
+        }
25
+
26
+        return newArray;
17 27
     }
18 28
 
19 29
     public static Double[] squares(Double... values) {
20
-        return null;
30
+        Double[] finalArray = new Double[values.length];
31
+        for(int i=0; i< finalArray.length; i++){
32
+            finalArray[i] = square(values[i]);
33
+        }
34
+        return finalArray;
21 35
     }
22 36
 
23 37
     public static Double add(Double value1, Double value2) {
24
-        return null;
38
+
39
+        return value1+value2;
25 40
     }
26 41
 
27 42
     public static Double subtract(Double value1, Double value2) {
28
-        return null;
43
+
44
+        return value1-value2;
29 45
     }
30 46
 
31 47
 
32 48
     public static Double divide(Double divisor, Double dividend) {
33
-        return null;
49
+
50
+        return divisor/dividend;
34 51
     }
35 52
 }