Yesoda Sanka пре 5 година
родитељ
комит
963593f63b

+ 3
- 6
src/main/java/rocks/zipcode/quiz5/collections/Bank.java Прегледај датотеку

@@ -18,12 +18,11 @@ public class Bank {
18 18
 
19 19
          addBankAccount(bankAccount );
20 20
 
21
-       if(containsBankAccount(bankAccount ) )
22
-
23
-           list.remove(indexNumber );
21
+       if(containsBankAccount(bankAccount ) ) {
24 22
 
23
+           list.remove(indexNumber);
24
+       }
25 25
         return (BankAccount) list;
26
-
27 26
     }
28 27
 
29 28
     public void addBankAccount(BankAccount bankAccount) {
@@ -34,8 +33,6 @@ public class Bank {
34 33
     public Boolean containsBankAccount(BankAccount bankAccount) {
35 34
     //throw new UnsupportedOperationException("Method not yet implemented");
36 35
 
37
-        Boolean flag;
38
-
39 36
         return list.contains(bankAccount );
40 37
     }
41 38
 }

+ 4
- 1
src/main/java/rocks/zipcode/quiz5/collections/Food.java Прегледај датотеку

@@ -3,6 +3,7 @@ package rocks.zipcode.quiz5.collections;
3 3
 import rocks.zipcode.quiz5.objectorientation.Spice;
4 4
 
5 5
 import java.util.ArrayList;
6
+import java.util.HashMap;
6 7
 import java.util.List;
7 8
 import java.util.Map;
8 9
 
@@ -13,6 +14,8 @@ public class Food  implements Spice {
13 14
 
14 15
     List<Spice>list=new ArrayList<>();
15 16
 
17
+   // Map<SpiceType,Integer >map=new HashMap<Spice,Integer>() >();
18
+
16 19
     public List<Spice> getAllSpices() {
17 20
 
18 21
         return list;
@@ -20,7 +23,7 @@ public class Food  implements Spice {
20 23
 
21 24
     public <SpiceType extends Class<? extends Spice>> Map<SpiceType, Integer> getSpiceCount() {
22 25
 
23
-        return null ;
26
+        return null;
24 27
     }
25 28
 
26 29
     public void applySpice(Spice spice) {

+ 3
- 1
src/main/java/rocks/zipcode/quiz5/fundamentals/Calculator.java Прегледај датотеку

@@ -32,7 +32,9 @@ public class Calculator {
32 32
     }
33 33
 
34 34
     public static Double[] squares(Double... values) {
35
+
35 36
         Double[] result = new Double[values .length];
37
+
36 38
         for(int i = 0; i < values .length ; i++ )
37 39
             result[i] = values [i]*values [i];
38 40
 
@@ -43,7 +45,7 @@ public class Calculator {
43 45
         DecimalFormat df = new DecimalFormat("0.00");
44 46
         Double result=value1 + value2;
45 47
 
46
-       System.out.println(df.format(result)) ;
48
+
47 49
 
48 50
        return result;
49 51
     }

+ 23
- 12
src/main/java/rocks/zipcode/quiz5/fundamentals/StringUtils.java Прегледај датотеку

@@ -1,6 +1,8 @@
1 1
 package rocks.zipcode.quiz5.fundamentals;
2 2
 
3 3
 import java.util.Arrays;
4
+import java.util.HashSet;
5
+import java.util.Set;
4 6
 
5 7
 /**
6 8
  * @author leon on 21/12/2018.
@@ -35,24 +37,32 @@ public class StringUtils {
35 37
         StringBuilder updateString = new StringBuilder(str);
36 38
         int middleIndex = str.length() /2;
37 39
         updateString.setCharAt(middleIndex, Character.toLowerCase(str.charAt(middleIndex)));
38
-        System.out.println(updateString);
40
+        //System.out.println(updateString);
39 41
         return updateString.toString() ;
40 42
 
41 43
     }
42 44
 
43 45
     public static Boolean isIsogram(String str) {
44 46
 
45
-        str = str.toLowerCase();
46
-        int len = str.length();
47
-
48
-        char arr[] = str.toCharArray();
49
-
50
-        Arrays.sort(arr);
51
-        for (int i = 0; i < len - 1; i++) {
52
-            if (arr[i] == arr[i + 1])
53
-                return false;
47
+//        str = str.toLowerCase();
48
+//        int len = str.length();
49
+//
50
+//        char arr[] = str.toCharArray();
51
+//
52
+//        Arrays.sort(arr);
53
+//        for (int i = 0; i < len - 1; i++) {
54
+//            if (arr[i] == arr[i + 1])
55
+//                return false;
56
+//        }
57
+//        return true;
58
+        String[] res=str.split("");
59
+        Set<String> set=new HashSet<String>(Arrays.asList(res) );
60
+        if(str.length()==set.size() ){
61
+            return true;
54 62
         }
55
-        return true;
63
+
64
+        else
65
+            return false;
56 66
     }
57 67
 
58 68
     public static Boolean hasDuplicateConsecutiveCharacters(String str) {
@@ -91,8 +101,9 @@ public class StringUtils {
91 101
 //        result=new String(ch);
92 102
 //
93 103
 //        return result;
104
+
94 105
         char[] chars = str.toCharArray();
95
-        int len = 0;      // Length of result (initially empty)
106
+        int len = 0;
96 107
 
97 108
         for (int i = 0; i < chars.length; i++) {
98 109
             if (len == 0 || chars[i] != chars[len - 1]) {

+ 15
- 2
src/main/java/rocks/zipcode/quiz5/objectorientation/account/Employee.java Прегледај датотеку

@@ -23,7 +23,6 @@ public class Employee  implements Transactable ,Worker {
23 23
         this.expectedBalance=getBalance() ;
24 24
         this.expectedBankAccountBalance =getBalance();
25 25
 
26
-
27 26
     }
28 27
 
29 28
     public BankAccount getBankAccount() {
@@ -36,9 +35,22 @@ public class Employee  implements Transactable ,Worker {
36 35
 
37 36
     }
38 37
 
39
-
38
+//    public void setExpectedHoursWorked(Double expectedHoursWorked ){
39
+//        this.expectedHoursWorked =expectedHoursWorked ;
40
+//    }
41
+//     public void setExpectedHourlyWage (Double expectedHourlyWage ){
42
+//        this.expectedHourlyWage =expectedHourlyWage;
43
+//     }
44
+//
45
+//     public void setExpectedBankAccountBalance (Double  expectedBankAccountBalance ){
46
+//        this.expectedBankAccountBalance=expectedBankAccountBalance ;
47
+//     }
48
+//     public void setExpectedBalance (Double expectedBalance ){
49
+//        this.expectedBalance =expectedBalance ;
50
+//     }
40 51
     @Override
41 52
     public void increaseHoursWorked(Double numberOfHours) {
53
+        expectedHoursWorked +=numberOfHours ;
42 54
 
43 55
     }
44 56
 
@@ -68,6 +80,7 @@ public class Employee  implements Transactable ,Worker {
68 80
 
69 81
     @Override
70 82
     public void withdrawal(Double amountToDecreaseBy) {
83
+
71 84
         expectedBalance-=amountToDecreaseBy;
72 85
     }
73 86