Skip to content

Commit 34c8d45

Browse files
committed
completed FizzBuzzGoldenMaster w/@samanthalangit
1 parent df5677f commit 34c8d45

2 files changed

Lines changed: 116 additions & 20 deletions

File tree

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,32 @@
11
package org.teachingkidsprogramming.recipes.completed.section09final;
22

3-
import org.junit.Ignore;
43
import org.junit.Test;
54
import org.teachingextensions.approvals.lite.Approvals;
65

7-
//********In Progress************************//
86
public class FizzBuzzGoldenMaster
97
{
10-
// Remove this when working - for build process only
11-
@Ignore
128
@Test
139
public void testNumbers() throws Exception
1410
{
15-
// Arrange - create a list of numbers from 1-20
16-
Integer[] numbers = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
17-
// Act - call the convertNumbers method on the list
18-
// Assert that the list is a Golden Master
19-
Approvals.verify(numbers);
20-
}
21-
public static String convertNumbers(Integer[] numbers)
22-
{
23-
for (Integer number : numbers)
11+
// Arrange - create a list of numbers from 1-100
12+
StringBuilder sb = new StringBuilder();
13+
for (int i = 1; i < 101; i++)
2414
{
25-
convert(number);
15+
// Act - call the convertNumbers method on the list
16+
sb.append(convert(i));
2617
}
27-
//need to fix or override the ToString here
28-
return ("" + numbers);
18+
// IMPORTANT - This testing method uses a file compare tool
19+
// You could use 'BeyondCompare' for this
20+
// Download from -- http://www.scootersoftware.com/download.php
21+
//
22+
// Assert that the list is a Golden Master (uses .received and .approved files)
23+
Approvals.verify(sb);
2924
}
3025
public static String convert(int i)
3126
{
32-
if (0 == i % 15) { return "\n FizzBuzz"; }
33-
if (0 == i % 5) { return "\n Buzz"; }
34-
if (0 == i % 3) { return "\n Fizz"; }
35-
return "" + i;
27+
if (0 == i % 15) { return "\nFizzBuzz"; }
28+
if (0 == i % 5) { return "\nBuzz"; }
29+
if (0 == i % 3) { return "\nFizz"; }
30+
return "\n" + i;
3631
}
3732
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
2+
1
3+
2
4+
Fizz
5+
4
6+
Buzz
7+
Fizz
8+
7
9+
8
10+
Fizz
11+
Buzz
12+
11
13+
Fizz
14+
13
15+
14
16+
FizzBuzz
17+
16
18+
17
19+
Fizz
20+
19
21+
Buzz
22+
Fizz
23+
22
24+
23
25+
Fizz
26+
Buzz
27+
26
28+
Fizz
29+
28
30+
29
31+
FizzBuzz
32+
31
33+
32
34+
Fizz
35+
34
36+
Buzz
37+
Fizz
38+
37
39+
38
40+
Fizz
41+
Buzz
42+
41
43+
Fizz
44+
43
45+
44
46+
FizzBuzz
47+
46
48+
47
49+
Fizz
50+
49
51+
Buzz
52+
Fizz
53+
52
54+
53
55+
Fizz
56+
Buzz
57+
56
58+
Fizz
59+
58
60+
59
61+
FizzBuzz
62+
61
63+
62
64+
Fizz
65+
64
66+
Buzz
67+
Fizz
68+
67
69+
68
70+
Fizz
71+
Buzz
72+
71
73+
Fizz
74+
73
75+
74
76+
FizzBuzz
77+
76
78+
77
79+
Fizz
80+
79
81+
Buzz
82+
Fizz
83+
82
84+
83
85+
Fizz
86+
Buzz
87+
86
88+
Fizz
89+
88
90+
89
91+
FizzBuzz
92+
91
93+
92
94+
Fizz
95+
94
96+
Buzz
97+
Fizz
98+
97
99+
98
100+
Fizz
101+
Buzz

0 commit comments

Comments
 (0)