Browse Source

half way?

Akeem Cherry 5 years ago
parent
commit
5577d22894

+ 8
- 4
src/main/java/rocks/zipcode/quiz5/fundamentals/Calculator.java View File

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

+ 24
- 4
src/main/java/rocks/zipcode/quiz5/fundamentals/StringUtils.java View File

@@ -5,7 +5,7 @@ package rocks.zipcode.quiz5.fundamentals;
5 5
  */
6 6
 public class StringUtils {
7 7
     public static Character getMiddleCharacter(String string) {
8
-        return null;
8
+        return string.charAt(string.length()/2);
9 9
     }
10 10
 
11 11
     public static String capitalizeMiddleCharacter(String str) {
@@ -17,15 +17,35 @@ public class StringUtils {
17 17
     }
18 18
 
19 19
     public static Boolean isIsogram(String str) {
20
-        return null;
20
+        for(int i = 0; i < str.length(); i++){
21
+            for (int j = i+1; j < str.length(); j++){
22
+                if (str.charAt(i) == str.charAt(j)){
23
+                    return false;
24
+                }
25
+            }
26
+        }
27
+
28
+        return true;
21 29
     }
22 30
 
23 31
     public static Boolean hasDuplicateConsecutiveCharacters(String str) {
24
-        return null;
32
+        for(int i = 0; i < str.length()-1; i++){
33
+            if(str.charAt(i) == str.charAt(i +1)){
34
+                return true;
35
+            }
36
+        }
37
+        return false;
25 38
     }
26 39
 
27 40
     public static String removeConsecutiveDuplicateCharacters(String str) {
28
-        return null;
41
+        String nString = new String();
42
+        int index = 0;
43
+        for (int i = 0; i < str.length(); i++){
44
+            char c = str.charAt(i);
45
+                nString += c;
46
+        }
47
+
48
+        return nString;
29 49
     }
30 50
 
31 51
     public static String invertCasing(String str) {

+ 21
- 1
src/main/java/rocks/zipcode/quiz5/objectorientation/account/Employee.java View File

@@ -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 Employee {
6
+public class Employee implements Worker{
7 7
     public Employee() {
8 8
     }
9 9
 
@@ -17,4 +17,24 @@ public class Employee {
17 17
     public void setBankAccount(BankAccount bankAccount) {
18 18
 
19 19
     }
20
+
21
+    @Override
22
+    public void increaseHoursWorked(Double numberOfHours) {
23
+
24
+    }
25
+
26
+    @Override
27
+    public Double getHoursWorked() {
28
+        return null;
29
+    }
30
+
31
+    @Override
32
+    public Double getHourlyWage() {
33
+        return null;
34
+    }
35
+
36
+    @Override
37
+    public Double getMoneyEarned() {
38
+        return null;
39
+    }
20 40
 }