Seth преди 5 години
родител
ревизия
c3c0288f7d
променени са 2 файла, в които са добавени 21 реда и са изтрити 7 реда
  1. 1
    0
      src/main/java/rocks/zipcode/quiz5/collections/Food.java
  2. 20
    7
      src/main/java/rocks/zipcode/quiz5/fundamentals/Calculator.java

+ 1
- 0
src/main/java/rocks/zipcode/quiz5/collections/Food.java Целия файл

@@ -9,6 +9,7 @@ import java.util.Map;
9 9
  * @author leon on 27/12/2018.
10 10
  */
11 11
 public class Food {
12
+
12 13
     public List<Spice> getAllSpices() {
13 14
         return null;
14 15
     }

+ 20
- 7
src/main/java/rocks/zipcode/quiz5/fundamentals/Calculator.java Целия файл

@@ -5,31 +5,44 @@ 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
+
14
+        return value * value;
13 15
     }
14 16
 
15 17
     public static Double[] squareRoots(Double... value) {
16
-        return null;
18
+        Double[] squareRoots = new Double[value.length];
19
+        for (int i = 0; i < value.length; i++) {
20
+            squareRoots[i] = Math.sqrt(value[i]);
21
+        }
22
+        return squareRoots;
17 23
     }
18 24
 
19 25
     public static Double[] squares(Double... values) {
20
-        return null;
26
+        Double[] squares = new Double[values.length];
27
+        for (int i = 0; i < squares.length ; i++) {
28
+            squares[i] = values[i] * values[i];
29
+        }
30
+        return squares;
21 31
     }
22 32
 
23 33
     public static Double add(Double value1, Double value2) {
24
-        return null;
34
+
35
+        return value1 + value2;
25 36
     }
26 37
 
27 38
     public static Double subtract(Double value1, Double value2) {
28
-        return null;
39
+
40
+        return value1 - value2;
29 41
     }
30 42
 
31 43
 
32 44
     public static Double divide(Double divisor, Double dividend) {
33
-        return null;
45
+
46
+        return divisor/dividend;
34 47
     }
35 48
 }