Kris Blassingame 6 gadus atpakaļ
vecāks
revīzija
2e21ee46dd

+ 10
- 2
src/main/java/io/zipcoder/StringsAndThings.java Parādīt failu

@@ -69,7 +69,8 @@ public class StringsAndThings {
69 69
      * gHappy("xxggyygxx") // Should return  false
70 70
      */
71 71
     public Boolean gIsHappy(String input) {
72
-        // int countG = (input.split("g", -1).length) - 1;
72
+
73
+
73 74
         int countGG = (input.split("gg", -1).length) - 1;
74 75
 
75 76
         if (countGG > 0) {
@@ -87,7 +88,14 @@ public class StringsAndThings {
87 88
      */
88 89
     public Integer countTriple(String input) {
89 90
 
90
-        return null;
91
+        String[] strArr = input.split("");
92
+        int counter = 0;
93
+        for (int i = 0; i < strArr.length - 2; i++) {
94
+            if (strArr[i].equals(strArr[i + 1]) && strArr[i].equals(strArr[i + 2])) {
95
+                counter++;
96
+            }
97
+        }
98
+        return counter;
91 99
     }
92 100
 }
93 101
 

+ 17
- 19
src/test/java/io/zipcoder/StringsAndThingsTest.java Parādīt failu

@@ -9,12 +9,12 @@ public class StringsAndThingsTest {
9 9
     private StringsAndThings stringsAndThings;
10 10
 
11 11
     @Before
12
-    public void setup(){
12
+    public void setup() {
13 13
         stringsAndThings = new StringsAndThings();
14 14
     }
15 15
 
16 16
     @Test
17
-    public void countYZTest1(){
17
+    public void countYZTest1() {
18 18
         String input = "fez day";
19 19
         Integer expected = 2;
20 20
         Integer actual = stringsAndThings.countYZ(input);
@@ -22,7 +22,7 @@ public class StringsAndThingsTest {
22 22
     }
23 23
 
24 24
     @Test
25
-    public void countYZTest2(){
25
+    public void countYZTest2() {
26 26
         String input = "day fez";
27 27
         Integer expected = 2;
28 28
         Integer actual = stringsAndThings.countYZ(input);
@@ -31,7 +31,7 @@ public class StringsAndThingsTest {
31 31
 
32 32
 
33 33
     @Test
34
-    public void countYZTest3 (){
34
+    public void countYZTest3() {
35 35
         String input = "day fyyyz";
36 36
         Integer expected = 2;
37 37
         Integer actual = stringsAndThings.countYZ(input);
@@ -39,82 +39,80 @@ public class StringsAndThingsTest {
39 39
     }
40 40
 
41 41
     @Test
42
-    public void withoutStringTest1(){
42
+    public void withoutStringTest1() {
43 43
         String expected = "He there";
44 44
         String actual = stringsAndThings.withoutString("Hello there", "llo");
45 45
         Assert.assertEquals(expected, actual);
46 46
     }
47 47
 
48 48
     @Test
49
-    public void withoutStringTest2(){
49
+    public void withoutStringTest2() {
50 50
         String expected = "Hllo thr";
51 51
         String actual = stringsAndThings.withoutString("Hello there", "e");
52 52
         Assert.assertEquals(expected, actual);
53 53
     }
54 54
 
55 55
     @Test
56
-    public void withoutStringTest3(){
56
+    public void withoutStringTest3() {
57 57
         String expected = "Hello there";
58 58
         String actual = stringsAndThings.withoutString("Hello there", "x");
59 59
         Assert.assertEquals(expected, actual);
60 60
     }
61 61
 
62 62
     @Test
63
-    public void equalIsNotTest1(){
63
+    public void equalIsNotTest1() {
64 64
         Boolean actual = stringsAndThings.equalIsNot("This is not");
65 65
         Assert.assertFalse(actual);
66 66
     }
67 67
 
68 68
     @Test
69
-    public void equalIsNotTest2(){
69
+    public void equalIsNotTest2() {
70 70
         Boolean actual = stringsAndThings.equalIsNot("This is notnot");
71 71
         Assert.assertTrue(actual);
72 72
     }
73 73
 
74 74
     @Test
75
-    public void equalIsNotTest3(){
75
+    public void equalIsNotTest3() {
76 76
         Boolean actual = stringsAndThings.equalIsNot("noisxxnotyynotxisi");
77 77
         Assert.assertTrue(actual);
78 78
     }
79 79
 
80 80
     @Test
81
-    public void gIsHappyTest1(){
81
+    public void gIsHappyTest1() {
82 82
         Boolean actual = stringsAndThings.gIsHappy("xxggxx");
83 83
         Assert.assertTrue(actual);
84 84
     }
85 85
 
86 86
     @Test
87
-    public void gIsHappyTest2(){
87
+    public void gIsHappyTest2() {
88 88
         Boolean actual = stringsAndThings.gIsHappy("xxgxx");
89 89
         Assert.assertFalse(actual);
90 90
     }
91 91
 
92 92
     @Test
93
-    public void gIsHappyTest3(){
93
+    public void gIsHappyTest3() {
94 94
         Boolean actual = stringsAndThings.gIsHappy("xxggyygxx");
95 95
         Assert.assertTrue(actual);
96 96
     }
97 97
 
98 98
     @Test
99
-    public void countTripleTest1(){
99
+    public void countTripleTest1() {
100 100
         Integer expected = 1;
101 101
         Integer actual = stringsAndThings.countTriple("abcXXXabc");
102 102
         Assert.assertEquals(expected, actual);
103 103
     }
104 104
 
105 105
     @Test
106
-    public void countTripleTest2(){
106
+    public void countTripleTest2() {
107 107
         Integer expected = 3;
108 108
         Integer actual = stringsAndThings.countTriple("xxxabyyyycd");
109 109
         Assert.assertEquals(expected, actual);
110 110
     }
111 111
 
112 112
     @Test
113
-    public void countTripleTest3(){
113
+    public void countTripleTest3() {
114 114
         Integer expected = 0;
115 115
         Integer actual = stringsAndThings.countTriple("a");
116 116
         Assert.assertEquals(expected, actual);
117 117
     }
118
-
119
-
120
-}
118
+}

Binārs
target/classes/io/zipcoder/StringsAndThings.class Parādīt failu