Browse Source

working on bank account

jacob andersen 5 years ago
parent
commit
ad436474bd

+ 1
- 1
src/main/java/rocks/zipcode/quiz5/collections/Bank.java View File

@@ -9,7 +9,7 @@ import java.util.ArrayList;
9 9
  */
10 10
 public class Bank {
11 11
 
12
-    ArrayList bank = new ArrayList<BankAccount>();
12
+    ArrayList<BankAccount> bank = new ArrayList<BankAccount>();
13 13
 
14 14
     BankAccount bankAccount = new BankAccount();
15 15
 

+ 23
- 2
src/main/java/rocks/zipcode/quiz5/fundamentals/StringUtils.java View File

@@ -1,5 +1,8 @@
1 1
 package rocks.zipcode.quiz5.fundamentals;
2 2
 
3
+import java.util.HashSet;
4
+import java.util.Set;
5
+
3 6
 /**
4 7
  * @author leon on 21/12/2018.
5 8
  */
@@ -40,16 +43,34 @@ public class StringUtils {
40 43
 
41 44
     public static Boolean isIsogram(String str)
42 45
     {
43
-        return null;
46
+        Set<Character> chars = new HashSet<Character>();
47
+        for (Character c : str.toCharArray()) {
48
+            // characters to ignore
49
+            if (c == ' ' || c == '-')
50
+                continue;
51
+            else if (chars.contains(Character.toUpperCase(c)))
52
+                return false;
53
+            else
54
+                chars.add(Character.toUpperCase(c));
55
+        }
56
+        return true;
44 57
     }
45 58
 
46 59
     public static Boolean hasDuplicateConsecutiveCharacters(String str)
47 60
     {
48
-        return null;
61
+        for (int i=0; i<str.length()-1;i++)
62
+        {
63
+            if(str.charAt(i)==str.charAt(i+1))
64
+            {
65
+                return true;
66
+            }
67
+        }
68
+        return false;
49 69
     }
50 70
 
51 71
     public static String removeConsecutiveDuplicateCharacters(String str)
52 72
     {
73
+
53 74
         return null;
54 75
     }
55 76
 

+ 1
- 1
src/main/java/rocks/zipcode/quiz5/objectorientation/Curry.java View File

@@ -1,4 +1,4 @@
1 1
 package rocks.zipcode.quiz5.objectorientation;
2 2
 
3
-public class Curry {
3
+public class Curry implements Spice {
4 4
 }

+ 1
- 1
src/main/java/rocks/zipcode/quiz5/objectorientation/Ginger.java View File

@@ -3,5 +3,5 @@ package rocks.zipcode.quiz5.objectorientation;
3 3
 /**
4 4
  * @author leon on 27/12/2018.
5 5
  */
6
-public class Ginger {
6
+public class Ginger implements Spice{
7 7
 }

+ 1
- 1
src/main/java/rocks/zipcode/quiz5/objectorientation/Pepper.java View File

@@ -3,5 +3,5 @@ package rocks.zipcode.quiz5.objectorientation;
3 3
 /**
4 4
  * @author leon on 27/12/2018.
5 5
  */
6
-public class Pepper {
6
+public class Pepper implements Spice{
7 7
 }

+ 1
- 1
src/main/java/rocks/zipcode/quiz5/objectorientation/account/Account.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 Account extends BankAccount {
6
+public class Account {
7 7
     public Long getId() {
8 8
         return null;
9 9
     }

+ 16
- 1
src/main/java/rocks/zipcode/quiz5/objectorientation/account/BankAccount.java View File

@@ -3,7 +3,22 @@ package rocks.zipcode.quiz5.objectorientation.account;
3 3
 /**
4 4
  * @author leon on 27/12/2018.
5 5
  */
6
-public class BankAccount {
6
+public class BankAccount extends Account implements Transactable {
7
+    @Override
8
+    public void deposit(Double amountToIncreaseBy) {
9
+
10
+    }
11
+
12
+    @Override
13
+    public void withdrawal(Double amountToDecreaseBy) {
14
+
15
+    }
16
+
7 17
     public void setBalance(Double val) {
8 18
     }
19
+
20
+    @Override
21
+    public Double getBalance() {
22
+        return null;
23
+    }
9 24
 }

+ 48
- 4
src/main/java/rocks/zipcode/quiz5/objectorientation/account/Employee.java View File

@@ -3,18 +3,62 @@ 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, Transactable{
7
+
8
+    BankAccount bankAccount = new BankAccount();
9
+
10
+
7 11
     public Employee() {
8 12
     }
9 13
 
10
-    public Employee(BankAccount bankAccount) {
14
+    public Employee(BankAccount bankAccount)
15
+    {
16
+
17
+    }
18
+
19
+    public BankAccount getBankAccount()
20
+    {
21
+        return bankAccount;
11 22
     }
12 23
 
13
-    public BankAccount getBankAccount() {
24
+    public void setBankAccount(BankAccount bankAccount)
25
+    {
26
+        this.bankAccount=bankAccount;
27
+    }
28
+
29
+    @Override
30
+    public void increaseHoursWorked(Double numberOfHours)
31
+    {
32
+
33
+    }
34
+
35
+    @Override
36
+    public Double getHoursWorked() {
14 37
         return null;
15 38
     }
16 39
 
17
-    public void setBankAccount(BankAccount bankAccount) {
40
+    @Override
41
+    public Double getHourlyWage() {
42
+        return null;
43
+    }
44
+
45
+    @Override
46
+    public Double getMoneyEarned() {
47
+        return null;
48
+    }
49
+
50
+    @Override
51
+    public void deposit(Double amountToIncreaseBy) {
18 52
 
19 53
     }
54
+
55
+    @Override
56
+    public void withdrawal(Double amountToDecreaseBy) {
57
+
58
+    }
59
+
60
+    @Override
61
+    public Double getBalance() {
62
+        return null;
63
+    }
20 64
 }

+ 1
- 1
src/test/java/rocks/zipcode/quiz5/fundamentals/stringutils/HasDuplicateConsecutiveCharactersTest.java View File

@@ -8,7 +8,7 @@ public class HasDuplicateConsecutiveCharactersTest {
8 8
     @Test
9 9
     public void test1() {
10 10
         String input = "Happy";
11
-        Assert.assertFalse(StringUtils.hasDuplicateConsecutiveCharacters(input));
11
+        Assert.assertTrue(StringUtils.hasDuplicateConsecutiveCharacters(input));
12 12
     }
13 13
 
14 14
     @Test