Browse Source

Actually done

Kris Blassingame 6 years ago
parent
commit
2e21ee46dd

+ 10
- 2
src/main/java/io/zipcoder/StringsAndThings.java View File

69
      * gHappy("xxggyygxx") // Should return  false
69
      * gHappy("xxggyygxx") // Should return  false
70
      */
70
      */
71
     public Boolean gIsHappy(String input) {
71
     public Boolean gIsHappy(String input) {
72
-        // int countG = (input.split("g", -1).length) - 1;
72
+
73
+
73
         int countGG = (input.split("gg", -1).length) - 1;
74
         int countGG = (input.split("gg", -1).length) - 1;
74
 
75
 
75
         if (countGG > 0) {
76
         if (countGG > 0) {
87
      */
88
      */
88
     public Integer countTriple(String input) {
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 View File

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

BIN
target/classes/io/zipcoder/StringsAndThings.class View File