Skip to content

Commit 930a744

Browse files
twelve-days: update to match specification
1 parent 7edb8c6 commit 930a744

4 files changed

Lines changed: 44 additions & 44 deletions

File tree

‎exercises/twelve-days/.meta/src/reference/java/TwelveDays.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class TwelveDays {
1818

1919
public String verse(int verseNumber) {
2020
StringBuilder stringBuilder = new StringBuilder("On the " + days[verseNumber - 1]
21-
+ " day of Christmas my true love gave to me, ");
21+
+ " day of Christmas my true love gave to me: ");
2222
for (int i = verseNumber; i > 0; i--) {
2323
if (verseNumber != 1 && i == 1) stringBuilder.append("and ");
2424
stringBuilder.append(gifts[i - 1]);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.0
1+
1.2.0

‎exercises/twelve-days/README.md‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,29 @@
33
Output the lyrics to 'The Twelve Days of Christmas'.
44

55
```text
6-
On the first day of Christmas my true love gave to me, a Partridge in a Pear Tree.
6+
On the first day of Christmas my true love gave to me: a Partridge in a Pear Tree.
77
8-
On the second day of Christmas my true love gave to me, two Turtle Doves, and a Partridge in a Pear Tree.
8+
On the second day of Christmas my true love gave to me: two Turtle Doves, and a Partridge in a Pear Tree.
99
10-
On the third day of Christmas my true love gave to me, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
10+
On the third day of Christmas my true love gave to me: three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
1111
12-
On the fourth day of Christmas my true love gave to me, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
12+
On the fourth day of Christmas my true love gave to me: four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
1313
14-
On the fifth day of Christmas my true love gave to me, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
14+
On the fifth day of Christmas my true love gave to me: five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
1515
16-
On the sixth day of Christmas my true love gave to me, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
16+
On the sixth day of Christmas my true love gave to me: six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
1717
18-
On the seventh day of Christmas my true love gave to me, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
18+
On the seventh day of Christmas my true love gave to me: seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
1919
20-
On the eighth day of Christmas my true love gave to me, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
20+
On the eighth day of Christmas my true love gave to me: eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
2121
22-
On the ninth day of Christmas my true love gave to me, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
22+
On the ninth day of Christmas my true love gave to me: nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
2323
24-
On the tenth day of Christmas my true love gave to me, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
24+
On the tenth day of Christmas my true love gave to me: ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
2525
26-
On the eleventh day of Christmas my true love gave to me, eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
26+
On the eleventh day of Christmas my true love gave to me: eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
2727
28-
On the twelfth day of Christmas my true love gave to me, twelve Drummers Drumming, eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
28+
On the twelfth day of Christmas my true love gave to me: twelve Drummers Drumming, eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
2929
```
3030

3131
# Running the tests

‎exercises/twelve-days/src/test/java/TwelveDaysTest.java‎

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,47 +14,47 @@ public void setup() {
1414

1515
@Test
1616
public void testVerseOne() {
17-
String expectedVerseOne = "On the first day of Christmas my true love gave to me, " +
17+
String expectedVerseOne = "On the first day of Christmas my true love gave to me: " +
1818
"a Partridge in a Pear Tree.\n";
1919
assertEquals(expectedVerseOne, twelveDays.verse(1));
2020
}
2121

2222
@Ignore("Remove to run test")
2323
@Test
2424
public void testVerseTwo() {
25-
String expectedVerseTwo = "On the second day of Christmas my true love gave to me, two Turtle Doves, " +
25+
String expectedVerseTwo = "On the second day of Christmas my true love gave to me: two Turtle Doves, " +
2626
"and a Partridge in a Pear Tree.\n";
2727
assertEquals(expectedVerseTwo, twelveDays.verse(2));
2828
}
2929

3030
@Ignore("Remove to run test")
3131
@Test
3232
public void testVerseThree() {
33-
String expectedVerseThree = "On the third day of Christmas my true love gave to me, three French Hens, " +
33+
String expectedVerseThree = "On the third day of Christmas my true love gave to me: three French Hens, " +
3434
"two Turtle Doves, and a Partridge in a Pear Tree.\n";
3535
assertEquals(expectedVerseThree, twelveDays.verse(3));
3636
}
3737

3838
@Ignore("Remove to run test")
3939
@Test
4040
public void testVerseFour() {
41-
String expectedVerseFour = "On the fourth day of Christmas my true love gave to me, four Calling Birds, " +
41+
String expectedVerseFour = "On the fourth day of Christmas my true love gave to me: four Calling Birds, " +
4242
"three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n";
4343
assertEquals(expectedVerseFour, twelveDays.verse(4));
4444
}
4545

4646
@Ignore("Remove to run test")
4747
@Test
4848
public void testVerseFive() {
49-
String expectedVerseFive = "On the fifth day of Christmas my true love gave to me, five Gold Rings, " +
49+
String expectedVerseFive = "On the fifth day of Christmas my true love gave to me: five Gold Rings, " +
5050
"four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n";
5151
assertEquals(expectedVerseFive, twelveDays.verse(5));
5252
}
5353

5454
@Ignore("Remove to run test")
5555
@Test
5656
public void testVerseSix() {
57-
String expectedVerseSix = "On the sixth day of Christmas my true love gave to me, six Geese-a-Laying, " +
57+
String expectedVerseSix = "On the sixth day of Christmas my true love gave to me: six Geese-a-Laying, " +
5858
"five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, " +
5959
"and a Partridge in a Pear Tree.\n";
6060
assertEquals(expectedVerseSix, twelveDays.verse(6));
@@ -63,7 +63,7 @@ public void testVerseSix() {
6363
@Ignore("Remove to run test")
6464
@Test
6565
public void testVerseSeven() {
66-
String expectedVerseSeven = "On the seventh day of Christmas my true love gave to me, " +
66+
String expectedVerseSeven = "On the seventh day of Christmas my true love gave to me: " +
6767
"seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, " +
6868
"two Turtle Doves, and a Partridge in a Pear Tree.\n";
6969
assertEquals(expectedVerseSeven, twelveDays.verse(7));
@@ -72,7 +72,7 @@ public void testVerseSeven() {
7272
@Ignore("Remove to run test")
7373
@Test
7474
public void testVerseEight() {
75-
String expectedVerseEight = "On the eighth day of Christmas my true love gave to me, eight Maids-a-Milking," +
75+
String expectedVerseEight = "On the eighth day of Christmas my true love gave to me: eight Maids-a-Milking," +
7676
" seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, " +
7777
"three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n";
7878
assertEquals(expectedVerseEight, twelveDays.verse(8));
@@ -81,7 +81,7 @@ public void testVerseEight() {
8181
@Ignore("Remove to run test")
8282
@Test
8383
public void testVerseNine() {
84-
String expectedVerseNine = "On the ninth day of Christmas my true love gave to me, nine Ladies Dancing, " +
84+
String expectedVerseNine = "On the ninth day of Christmas my true love gave to me: nine Ladies Dancing, " +
8585
"eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, " +
8686
"four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n";
8787
assertEquals(expectedVerseNine, twelveDays.verse(9));
@@ -90,7 +90,7 @@ public void testVerseNine() {
9090
@Ignore("Remove to run test")
9191
@Test
9292
public void testVerseTen() {
93-
String expectedVerseTen = "On the tenth day of Christmas my true love gave to me, ten Lords-a-Leaping, " +
93+
String expectedVerseTen = "On the tenth day of Christmas my true love gave to me: ten Lords-a-Leaping, " +
9494
"nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, " +
9595
"five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, " +
9696
"and a Partridge in a Pear Tree.\n";
@@ -100,7 +100,7 @@ public void testVerseTen() {
100100
@Ignore("Remove to run test")
101101
@Test
102102
public void testVerseEleven() {
103-
String expectedVerseEleven = "On the eleventh day of Christmas my true love gave to me, " +
103+
String expectedVerseEleven = "On the eleventh day of Christmas my true love gave to me: " +
104104
"eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, " +
105105
"seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, " +
106106
"three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n";
@@ -110,7 +110,7 @@ public void testVerseEleven() {
110110
@Ignore("Remove to run test")
111111
@Test
112112
public void testVerseTwelve() {
113-
String expectedVerseTwelve = "On the twelfth day of Christmas my true love gave to me, " +
113+
String expectedVerseTwelve = "On the twelfth day of Christmas my true love gave to me: " +
114114
"twelve Drummers Drumming, eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, " +
115115
"eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, " +
116116
"four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n";
@@ -120,69 +120,69 @@ public void testVerseTwelve() {
120120
@Ignore("Remove to run test")
121121
@Test
122122
public void testFirstThreeVerses() {
123-
String expectedVersesOneToThree = "On the first day of Christmas my true love gave to me, " +
123+
String expectedVersesOneToThree = "On the first day of Christmas my true love gave to me: " +
124124
"a Partridge in a Pear Tree.\n\n" +
125-
"On the second day of Christmas my true love gave to me, two Turtle Doves, " +
125+
"On the second day of Christmas my true love gave to me: two Turtle Doves, " +
126126
"and a Partridge in a Pear Tree.\n\n" +
127-
"On the third day of Christmas my true love gave to me, three French Hens, two Turtle Doves, " +
127+
"On the third day of Christmas my true love gave to me: three French Hens, two Turtle Doves, " +
128128
"and a Partridge in a Pear Tree.\n";
129129
assertEquals(expectedVersesOneToThree, twelveDays.verses(1, 3));
130130
}
131131

132132
@Ignore("Remove to run test")
133133
@Test
134134
public void testFourthToSixthVerses() {
135-
String expectedVersesFourToSix = "On the fourth day of Christmas my true love gave to me, " +
135+
String expectedVersesFourToSix = "On the fourth day of Christmas my true love gave to me: " +
136136
"four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n\n" +
137-
"On the fifth day of Christmas my true love gave to me, five Gold Rings, four Calling Birds, " +
137+
"On the fifth day of Christmas my true love gave to me: five Gold Rings, four Calling Birds, " +
138138
"three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n\n" +
139-
"On the sixth day of Christmas my true love gave to me, six Geese-a-Laying, five Gold Rings, " +
139+
"On the sixth day of Christmas my true love gave to me: six Geese-a-Laying, five Gold Rings, " +
140140
"four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n";
141141
assertEquals(expectedVersesFourToSix, twelveDays.verses(4, 6));
142142
}
143143

144144
@Ignore("Remove to run test")
145145
@Test
146146
public void testSingWholeSong() {
147-
String expectedSong = "On the first day of Christmas my true love gave to me, a Partridge in a Pear Tree.\n" +
147+
String expectedSong = "On the first day of Christmas my true love gave to me: a Partridge in a Pear Tree.\n" +
148148
"\n" +
149-
"On the second day of Christmas my true love gave to me, two Turtle Doves, " +
149+
"On the second day of Christmas my true love gave to me: two Turtle Doves, " +
150150
"and a Partridge in a Pear Tree.\n" +
151151
"\n" +
152-
"On the third day of Christmas my true love gave to me, three French Hens, two Turtle Doves, " +
152+
"On the third day of Christmas my true love gave to me: three French Hens, two Turtle Doves, " +
153153
"and a Partridge in a Pear Tree.\n" +
154154
"\n" +
155-
"On the fourth day of Christmas my true love gave to me, four Calling Birds, three French Hens, " +
155+
"On the fourth day of Christmas my true love gave to me: four Calling Birds, three French Hens, " +
156156
"two Turtle Doves, and a Partridge in a Pear Tree.\n" +
157157
"\n" +
158-
"On the fifth day of Christmas my true love gave to me, five Gold Rings, four Calling Birds, " +
158+
"On the fifth day of Christmas my true love gave to me: five Gold Rings, four Calling Birds, " +
159159
"three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n" +
160160
"\n" +
161-
"On the sixth day of Christmas my true love gave to me, six Geese-a-Laying, five Gold Rings, " +
161+
"On the sixth day of Christmas my true love gave to me: six Geese-a-Laying, five Gold Rings, " +
162162
"four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n" +
163163
"\n" +
164-
"On the seventh day of Christmas my true love gave to me, seven Swans-a-Swimming, " +
164+
"On the seventh day of Christmas my true love gave to me: seven Swans-a-Swimming, " +
165165
"six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, " +
166166
"and a Partridge in a Pear Tree.\n" +
167167
"\n" +
168-
"On the eighth day of Christmas my true love gave to me, eight Maids-a-Milking, " +
168+
"On the eighth day of Christmas my true love gave to me: eight Maids-a-Milking, " +
169169
"seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, " +
170170
"three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n" +
171171
"\n" +
172-
"On the ninth day of Christmas my true love gave to me, nine Ladies Dancing, eight Maids-a-Milking," +
172+
"On the ninth day of Christmas my true love gave to me: nine Ladies Dancing, eight Maids-a-Milking," +
173173
" seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, " +
174174
"three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n" +
175175
"\n" +
176-
"On the tenth day of Christmas my true love gave to me, ten Lords-a-Leaping, nine Ladies Dancing," +
176+
"On the tenth day of Christmas my true love gave to me: ten Lords-a-Leaping, nine Ladies Dancing," +
177177
" eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, " +
178178
"four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n" +
179179
"\n" +
180-
"On the eleventh day of Christmas my true love gave to me, eleven Pipers Piping, " +
180+
"On the eleventh day of Christmas my true love gave to me: eleven Pipers Piping, " +
181181
"ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, " +
182182
"six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, " +
183183
"and a Partridge in a Pear Tree.\n" +
184184
"\n" +
185-
"On the twelfth day of Christmas my true love gave to me, twelve Drummers Drumming, " +
185+
"On the twelfth day of Christmas my true love gave to me: twelve Drummers Drumming, " +
186186
"eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, " +
187187
"seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, " +
188188
"three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n";

0 commit comments

Comments
 (0)