Pārlūkot izejas kodu

Scoresheet Tests

Lauren Green 6 gadus atpakaļ
vecāks
revīzija
d3f172776f

+ 16
- 6
src/main/java/io/zipcoder/casino/ScoreSheet.java Parādīt failu

@@ -21,21 +21,31 @@ public class ScoreSheet {
21 21
     public int getTotalScore() {
22 22
 
23 23
         int totalScore = 0;
24
-        totalScore = (totalScore + getScore(ScoreSheet.ROW.ACES) + getScore(ScoreSheet.ROW.TWOS) + getScore(ScoreSheet.ROW.THREES) + getScore(ScoreSheet.ROW.FOURS) + getScore(ScoreSheet.ROW.FIVES) + getScore(ScoreSheet.ROW.SIXES));
25
-        if (totalScore >= 63) {
24
+        int upperScore = 0;
25
+        int lowerScore = 0;
26
+        try {
27
+            upperScore = getScore(ScoreSheet.ROW.ACES) + getScore(ScoreSheet.ROW.TWOS) + getScore(ScoreSheet.ROW.THREES) + getScore(ScoreSheet.ROW.FOURS) + getScore(ScoreSheet.ROW.FIVES) + getScore(ScoreSheet.ROW.SIXES);
28
+        } catch (NullPointerException e){
29
+            upperScore = 0;
30
+        }
31
+        try {
32
+            lowerScore = getScore(ScoreSheet.ROW.THREEOFAKIND) + getScore(ScoreSheet.ROW.FOUROFAKIND) + getScore(ScoreSheet.ROW.FULLHOUSE) + getScore(ScoreSheet.ROW.SMALLSTRAIGHT) + getScore(ScoreSheet.ROW.LARGESTRAIGHT) + getScore(ScoreSheet.ROW.YAHTZEE) + getScore(ScoreSheet.ROW.CHANCE);
33
+        } catch (NullPointerException e){
34
+            lowerScore = 0;
35
+        }
36
+        if (upperScore >= 63) {
26 37
             totalScore += 35;
27 38
         }
28
-        totalScore = (totalScore + getScore(ScoreSheet.ROW.THREEOFAKIND) + getScore(ScoreSheet.ROW.FOUROFAKIND) + getScore(ScoreSheet.ROW.FULLHOUSE) + getScore(ScoreSheet.ROW.SMALLSTRAIGHT) + getScore(ScoreSheet.ROW.LARGESTRAIGHT) + getScore(ScoreSheet.ROW.YAHTZEE) + getScore(ScoreSheet.ROW.CHANCE));
29
-
39
+        totalScore = totalScore + upperScore + lowerScore;
30 40
         return totalScore;
31 41
     }
32 42
 
33 43
     public String rowToString(ROW row, String description) {
34 44
         String rowInfo = String.format("%-35s",description);
35 45
         if(getScore(row) != null) {
36
-            rowInfo += "\n** " + getScore(row) + " **\n";
46
+            rowInfo += "** " + getScore(row) + " **\n";
37 47
         } else {
38
-            rowInfo += "\n** open **\n";
48
+            rowInfo += "** open **\n";
39 49
         }
40 50
         return rowInfo;
41 51
     }

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

@@ -131,7 +131,7 @@ public class Yahtzee extends DiceGame implements Game, Gamble {
131 131
         ScoreSheet.ROW row = ScoreSheet.ROW.CHANCE;
132 132
 
133 133
         while (validEntry) {
134
-            dicePlayer.getScoreSheet().printScoreCard();
134
+            Printer.printMessage(dicePlayer.getScoreSheet().scoreCardToString());
135 135
             System.out.println();
136 136
             System.out.println("Which row would you like to apply your turn to on the scoresheet?.\n" +
137 137
                     "Remember you can only use each row once!");
@@ -190,7 +190,7 @@ public class Yahtzee extends DiceGame implements Game, Gamble {
190 190
 
191 191
         dicePlayer.getScoreSheet().setRow(row, dicePlayer.getCup());
192 192
         System.out.println();
193
-        dicePlayer.getScoreSheet().printScoreCard();
193
+        Printer.printMessage(dicePlayer.getScoreSheet().scoreCardToString());
194 194
     }
195 195
 
196 196
     @Override

+ 258
- 319
src/test/java/io/zipcoder/casino/ScoreSheetTest.java Parādīt failu

@@ -9,10 +9,18 @@ import java.util.Collections;
9 9
 
10 10
 public class ScoreSheetTest {
11 11
 
12
+    ScoreSheet scoreSheet = new ScoreSheet();
13
+    Dice dice1 = new Dice();
14
+    Dice dice2 = new Dice();
15
+    Dice dice3 = new Dice();
16
+    Dice dice4 = new Dice();
17
+    Dice dice5 = new Dice();
18
+    Dice[] cup = new Dice[5];
19
+
20
+
12 21
     @Test
13 22
     public void testCheckThreeOfAKindFalse() {
14 23
         //Given
15
-        ScoreSheet scoreSheet = new ScoreSheet();
16 24
         ArrayList<Integer> test = new ArrayList<>();
17 25
         test.add(5);
18 26
         test.add(3);
@@ -28,7 +36,6 @@ public class ScoreSheetTest {
28 36
     @Test
29 37
     public void testCheckThreeOfAKindTrue() {
30 38
         //Given
31
-        ScoreSheet scoreSheet = new ScoreSheet();
32 39
         ArrayList<Integer> test = new ArrayList<>();
33 40
         test.add(2);
34 41
         test.add(3);
@@ -44,7 +51,6 @@ public class ScoreSheetTest {
44 51
     @Test
45 52
     public void testCheckFourOfAKindFalse() {
46 53
         //Given
47
-        ScoreSheet scoreSheet = new ScoreSheet();
48 54
         ArrayList<Integer> test = new ArrayList<>();
49 55
         test.add(5);
50 56
         test.add(3);
@@ -60,7 +66,6 @@ public class ScoreSheetTest {
60 66
     @Test
61 67
     public void testCheckFourOfAKindTrue() {
62 68
         //Given
63
-        ScoreSheet scoreSheet = new ScoreSheet();
64 69
         ArrayList<Integer> test = new ArrayList<>();
65 70
         test.add(2);
66 71
         test.add(3);
@@ -76,7 +81,6 @@ public class ScoreSheetTest {
76 81
     @Test
77 82
     public void testCheckYahtzeeFalse() {
78 83
         //Given
79
-        ScoreSheet scoreSheet = new ScoreSheet();
80 84
         ArrayList<Integer> test = new ArrayList<>();
81 85
         test.add(5);
82 86
         test.add(3);
@@ -92,7 +96,6 @@ public class ScoreSheetTest {
92 96
     @Test
93 97
     public void testCheckYahtzeeTrue() {
94 98
         //Given
95
-        ScoreSheet scoreSheet = new ScoreSheet();
96 99
         ArrayList<Integer> test = new ArrayList<>();
97 100
         test.add(2);
98 101
         test.add(2);
@@ -108,7 +111,6 @@ public class ScoreSheetTest {
108 111
     @Test
109 112
     public void testCheckFullHouseFalse() {
110 113
         //Given
111
-        ScoreSheet scoreSheet = new ScoreSheet();
112 114
         ArrayList<Integer> test = new ArrayList<>();
113 115
         test.add(5);
114 116
         test.add(3);
@@ -124,7 +126,6 @@ public class ScoreSheetTest {
124 126
     @Test
125 127
     public void testCheckFullHouseTrue() {
126 128
         //Given
127
-        ScoreSheet scoreSheet = new ScoreSheet();
128 129
         ArrayList<Integer> test = new ArrayList<>();
129 130
         test.add(2);
130 131
         test.add(3);
@@ -140,7 +141,6 @@ public class ScoreSheetTest {
140 141
     @Test
141 142
     public void testCheckLargeStraightFalse() {
142 143
         //Given
143
-        ScoreSheet scoreSheet = new ScoreSheet();
144 144
         ArrayList<Integer> test = new ArrayList<>();
145 145
         test.add(5);
146 146
         test.add(3);
@@ -157,7 +157,6 @@ public class ScoreSheetTest {
157 157
     @Test
158 158
     public void testCheckLargeStraightTrue() {
159 159
         //Given
160
-        ScoreSheet scoreSheet = new ScoreSheet();
161 160
         ArrayList<Integer> test = new ArrayList<>();
162 161
         test.add(2);
163 162
         test.add(3);
@@ -174,7 +173,6 @@ public class ScoreSheetTest {
174 173
     @Test
175 174
     public void testCheckSmallStraightFalse() {
176 175
         //Given
177
-        ScoreSheet scoreSheet = new ScoreSheet();
178 176
         ArrayList<Integer> test = new ArrayList<>();
179 177
         test.add(5);
180 178
         test.add(3);
@@ -191,7 +189,6 @@ public class ScoreSheetTest {
191 189
     @Test
192 190
     public void testCheckSmallStraightTrue1() {
193 191
         //Given
194
-        ScoreSheet scoreSheet = new ScoreSheet();
195 192
         ArrayList<Integer> test = new ArrayList<>();
196 193
         test.add(5);
197 194
         test.add(3);
@@ -208,7 +205,6 @@ public class ScoreSheetTest {
208 205
     @Test
209 206
     public void testCheckSmallStraightTrue2() {
210 207
         //Given
211
-        ScoreSheet scoreSheet = new ScoreSheet();
212 208
         ArrayList<Integer> test = new ArrayList<>();
213 209
         test.add(1);
214 210
         test.add(3);
@@ -225,7 +221,6 @@ public class ScoreSheetTest {
225 221
     @Test
226 222
     public void testCheckSmallStraightTrue3() {
227 223
         //Given
228
-        ScoreSheet scoreSheet = new ScoreSheet();
229 224
         ArrayList<Integer> test = new ArrayList<>();
230 225
         test.add(1);
231 226
         test.add(3);
@@ -242,7 +237,6 @@ public class ScoreSheetTest {
242 237
     @Test
243 238
     public void testScoreNumbers() {
244 239
         //Given
245
-        ScoreSheet scoreSheet = new ScoreSheet();
246 240
         ArrayList<Integer> test = new ArrayList<>();
247 241
         test.add(2);
248 242
         test.add(3);
@@ -262,7 +256,6 @@ public class ScoreSheetTest {
262 256
     @Test
263 257
     public void testScoreTotalDice() {
264 258
         //Given
265
-        ScoreSheet scoreSheet = new ScoreSheet();
266 259
         ArrayList<Integer> test = new ArrayList<>();
267 260
         test.add(2);
268 261
         test.add(3);
@@ -282,13 +275,6 @@ public class ScoreSheetTest {
282 275
     @Test
283 276
     public void testSetRowCHANCE() {
284 277
         //Given
285
-        ScoreSheet scoreSheet = new ScoreSheet();
286
-        Dice dice1 = new Dice();
287
-        Dice dice2 = new Dice();
288
-        Dice dice3 = new Dice();
289
-        Dice dice4 = new Dice();
290
-        Dice dice5 = new Dice();
291
-        Dice[] cup = new Dice[5];
292 278
         cup[0] = dice1;
293 279
         cup[1] = dice2;
294 280
         cup[2] = dice3;
@@ -299,363 +285,316 @@ public class ScoreSheetTest {
299 285
         }
300 286
         int expected = dice1.getValue() + dice2.getValue() + dice3.getValue() + dice4.getValue() + dice5.getValue();
301 287
 
302
-        //When
303
-
304
-        scoreSheet.setRow(ScoreSheet.ROW.CHANCE, cup);
305
-        int actual = scoreSheet.getScore(ScoreSheet.ROW.CHANCE);
288
+            //When
289
+            scoreSheet.setRow(ScoreSheet.ROW.CHANCE, cup);
290
+            int actual = scoreSheet.getScore(ScoreSheet.ROW.CHANCE);
306 291
 
307
-        //Then
308
-        Assert.assertEquals(expected, actual);
292
+            //Then
293
+            Assert.assertEquals(expected, actual);
309 294
 
310
-    }
311
-
312
-    @Test
313
-    public void testSetRowACES() {
314
-        //Given
315
-        ScoreSheet scoreSheet = new ScoreSheet();
316
-        Dice dice1 = new Dice();
317
-        Dice dice2 = new Dice();
318
-        Dice dice3 = new Dice();
319
-        Dice dice4 = new Dice();
320
-        Dice dice5 = new Dice();
321
-        Dice[] cup = new Dice[5];
322
-        cup[0] = dice1;
323
-        cup[1] = dice2;
324
-        cup[2] = dice3;
325
-        cup[3] = dice4;
326
-        cup[4] = dice5;
327
-        for (Dice d : cup) {
328
-            d.roll();
329 295
         }
330 296
 
331
-        //When
332
-        scoreSheet.setRow(ScoreSheet.ROW.ACES, cup);
297
+        @Test
298
+        public void testSetRowACES () {
299
+            //Given
300
+            cup[0] = dice1;
301
+            cup[1] = dice2;
302
+            cup[2] = dice3;
303
+            cup[3] = dice4;
304
+            cup[4] = dice5;
305
+            for (Dice d : cup) {
306
+                d.roll();
307
+            }
333 308
 
309
+            //When
310
+            scoreSheet.setRow(ScoreSheet.ROW.ACES, cup);
334 311
 
335
-        //Then
336
-        Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.ACES) != null));
337 312
 
338
-    }
313
+            //Then
314
+            Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.ACES) != null));
339 315
 
340
-    @Test
341
-    public void testSetRowTWOS() {
342
-        //Given
343
-        ScoreSheet scoreSheet = new ScoreSheet();
344
-        Dice dice1 = new Dice();
345
-        Dice dice2 = new Dice();
346
-        Dice dice3 = new Dice();
347
-        Dice dice4 = new Dice();
348
-        Dice dice5 = new Dice();
349
-        Dice[] cup = new Dice[5];
350
-        cup[0] = dice1;
351
-        cup[1] = dice2;
352
-        cup[2] = dice3;
353
-        cup[3] = dice4;
354
-        cup[4] = dice5;
355
-        for (Dice d : cup) {
356
-            d.roll();
357 316
         }
358 317
 
359
-        //When
360
-        scoreSheet.setRow(ScoreSheet.ROW.TWOS, cup);
318
+        @Test
319
+        public void testSetRowTWOS () {
320
+            //Given
321
+            cup[0] = dice1;
322
+            cup[1] = dice2;
323
+            cup[2] = dice3;
324
+            cup[3] = dice4;
325
+            cup[4] = dice5;
326
+            for (Dice d : cup) {
327
+                d.roll();
328
+            }
361 329
 
330
+            //When
331
+            scoreSheet.setRow(ScoreSheet.ROW.TWOS, cup);
362 332
 
363
-        //Then
364
-        Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.TWOS) != null));
365 333
 
366
-    }
334
+            //Then
335
+            Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.TWOS) != null));
367 336
 
368
-    @Test
369
-    public void testSetRowTHREES() {
370
-        //Given
371
-        ScoreSheet scoreSheet = new ScoreSheet();
372
-        Dice dice1 = new Dice();
373
-        Dice dice2 = new Dice();
374
-        Dice dice3 = new Dice();
375
-        Dice dice4 = new Dice();
376
-        Dice dice5 = new Dice();
377
-        Dice[] cup = new Dice[5];
378
-        cup[0] = dice1;
379
-        cup[1] = dice2;
380
-        cup[2] = dice3;
381
-        cup[3] = dice4;
382
-        cup[4] = dice5;
383
-        for (Dice d : cup) {
384
-            d.roll();
385 337
         }
386 338
 
387
-        //When
388
-        scoreSheet.setRow(ScoreSheet.ROW.THREES, cup);
339
+        @Test
340
+        public void testSetRowTHREES () {
341
+            //Given
342
+            cup[0] = dice1;
343
+            cup[1] = dice2;
344
+            cup[2] = dice3;
345
+            cup[3] = dice4;
346
+            cup[4] = dice5;
347
+            for (Dice d : cup) {
348
+                d.roll();
349
+            }
389 350
 
351
+            //When
352
+            scoreSheet.setRow(ScoreSheet.ROW.THREES, cup);
390 353
 
391
-        //Then
392
-        Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.THREES) != null));
393 354
 
394
-    }
355
+            //Then
356
+            Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.THREES) != null));
395 357
 
396
-    @Test
397
-    public void testSetRowFOURS() {
398
-        //Given
399
-        ScoreSheet scoreSheet = new ScoreSheet();
400
-        Dice dice1 = new Dice();
401
-        Dice dice2 = new Dice();
402
-        Dice dice3 = new Dice();
403
-        Dice dice4 = new Dice();
404
-        Dice dice5 = new Dice();
405
-        Dice[] cup = new Dice[5];
406
-        cup[0] = dice1;
407
-        cup[1] = dice2;
408
-        cup[2] = dice3;
409
-        cup[3] = dice4;
410
-        cup[4] = dice5;
411
-        for (Dice d : cup) {
412
-            d.roll();
413 358
         }
414 359
 
415
-        //When
416
-        scoreSheet.setRow(ScoreSheet.ROW.FOURS, cup);
360
+        @Test
361
+        public void testSetRowFOURS () {
362
+            //Given
363
+            cup[0] = dice1;
364
+            cup[1] = dice2;
365
+            cup[2] = dice3;
366
+            cup[3] = dice4;
367
+            cup[4] = dice5;
368
+            for (Dice d : cup) {
369
+                d.roll();
370
+            }
417 371
 
372
+            //When
373
+            scoreSheet.setRow(ScoreSheet.ROW.FOURS, cup);
418 374
 
419
-        //Then
420
-        Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.FOURS) != null));
421 375
 
422
-    }
376
+            //Then
377
+            Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.FOURS) != null));
423 378
 
424
-    @Test
425
-    public void testSetRowFIVES() {
426
-        //Given
427
-        ScoreSheet scoreSheet = new ScoreSheet();
428
-        Dice dice1 = new Dice();
429
-        Dice dice2 = new Dice();
430
-        Dice dice3 = new Dice();
431
-        Dice dice4 = new Dice();
432
-        Dice dice5 = new Dice();
433
-        Dice[] cup = new Dice[5];
434
-        cup[0] = dice1;
435
-        cup[1] = dice2;
436
-        cup[2] = dice3;
437
-        cup[3] = dice4;
438
-        cup[4] = dice5;
439
-        for (Dice d : cup) {
440
-            d.roll();
441 379
         }
442 380
 
443
-        //When
444
-        scoreSheet.setRow(ScoreSheet.ROW.FIVES, cup);
381
+        @Test
382
+        public void testSetRowFIVES () {
383
+            //Given
384
+            cup[0] = dice1;
385
+            cup[1] = dice2;
386
+            cup[2] = dice3;
387
+            cup[3] = dice4;
388
+            cup[4] = dice5;
389
+            for (Dice d : cup) {
390
+                d.roll();
391
+            }
445 392
 
393
+            //When
394
+            scoreSheet.setRow(ScoreSheet.ROW.FIVES, cup);
446 395
 
447
-        //Then
448
-        Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.FIVES) != null));
449 396
 
450
-    }
397
+            //Then
398
+            Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.FIVES) != null));
451 399
 
452
-    @Test
453
-    public void testSetRowSIXES() {
454
-        //Given
455
-        ScoreSheet scoreSheet = new ScoreSheet();
456
-        Dice dice1 = new Dice();
457
-        Dice dice2 = new Dice();
458
-        Dice dice3 = new Dice();
459
-        Dice dice4 = new Dice();
460
-        Dice dice5 = new Dice();
461
-        Dice[] cup = new Dice[5];
462
-        cup[0] = dice1;
463
-        cup[1] = dice2;
464
-        cup[2] = dice3;
465
-        cup[3] = dice4;
466
-        cup[4] = dice5;
467
-        for (Dice d : cup) {
468
-            d.roll();
469 400
         }
470 401
 
471
-        //When
472
-        scoreSheet.setRow(ScoreSheet.ROW.SIXES, cup);
402
+        @Test
403
+        public void testSetRowSIXES () {
404
+            //Given
405
+            cup[0] = dice1;
406
+            cup[1] = dice2;
407
+            cup[2] = dice3;
408
+            cup[3] = dice4;
409
+            cup[4] = dice5;
410
+            for (Dice d : cup) {
411
+                d.roll();
412
+            }
473 413
 
414
+            //When
415
+            scoreSheet.setRow(ScoreSheet.ROW.SIXES, cup);
474 416
 
475
-        //Then
476
-        Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.SIXES) != null));
477 417
 
478
-    }
418
+            //Then
419
+            Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.SIXES) != null));
479 420
 
480
-    @Test
481
-    public void testSetRowThreeOfAKind() {
482
-        //Given
483
-        ScoreSheet scoreSheet = new ScoreSheet();
484
-        Dice dice1 = new Dice();
485
-        Dice dice2 = new Dice();
486
-        Dice dice3 = new Dice();
487
-        Dice dice4 = new Dice();
488
-        Dice dice5 = new Dice();
489
-        Dice[] cup = new Dice[5];
490
-        cup[0] = dice1;
491
-        cup[1] = dice2;
492
-        cup[2] = dice3;
493
-        cup[3] = dice4;
494
-        cup[4] = dice5;
495
-        for (Dice d : cup) {
496
-            d.roll();
497
-        }
498
-
499
-        //When
500
-        scoreSheet.setRow(ScoreSheet.ROW.THREEOFAKIND, cup);
501
-
502
-
503
-        //Then
504
-        Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.THREEOFAKIND) != null));
505
-
506
-    }
507
-
508
-    @Test
509
-    public void testSetRowFourOfAKind() {
510
-        //Given
511
-        ScoreSheet scoreSheet = new ScoreSheet();
512
-        Dice dice1 = new Dice();
513
-        Dice dice2 = new Dice();
514
-        Dice dice3 = new Dice();
515
-        Dice dice4 = new Dice();
516
-        Dice dice5 = new Dice();
517
-        Dice[] cup = new Dice[5];
518
-        cup[0] = dice1;
519
-        cup[1] = dice2;
520
-        cup[2] = dice3;
521
-        cup[3] = dice4;
522
-        cup[4] = dice5;
523
-        for (Dice d : cup) {
524
-            d.roll();
525
-        }
526
-
527
-        //When
528
-        scoreSheet.setRow(ScoreSheet.ROW.FOUROFAKIND, cup);
529
-
530
-
531
-        //Then
532
-        Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.FOUROFAKIND) != null));
533
-
534
-    }
535
-
536
-    @Test
537
-    public void testSetRowFullHouse() {
538
-        //Given
539
-        ScoreSheet scoreSheet = new ScoreSheet();
540
-        Dice dice1 = new Dice();
541
-        Dice dice2 = new Dice();
542
-        Dice dice3 = new Dice();
543
-        Dice dice4 = new Dice();
544
-        Dice dice5 = new Dice();
545
-        Dice[] cup = new Dice[5];
546
-        cup[0] = dice1;
547
-        cup[1] = dice2;
548
-        cup[2] = dice3;
549
-        cup[3] = dice4;
550
-        cup[4] = dice5;
551
-        for (Dice d : cup) {
552
-            d.roll();
553
-        }
554
-
555
-        //When
556
-        scoreSheet.setRow(ScoreSheet.ROW.FULLHOUSE, cup);
557
-
558
-
559
-        //Then
560
-        Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.FULLHOUSE) != null));
561
-
562
-    }
563
-
564
-    @Test
565
-    public void testSetRowSmallStraight() {
566
-        //Given
567
-        ScoreSheet scoreSheet = new ScoreSheet();
568
-        Dice dice1 = new Dice();
569
-        Dice dice2 = new Dice();
570
-        Dice dice3 = new Dice();
571
-        Dice dice4 = new Dice();
572
-        Dice dice5 = new Dice();
573
-        Dice[] cup = new Dice[5];
574
-        cup[0] = dice1;
575
-        cup[1] = dice2;
576
-        cup[2] = dice3;
577
-        cup[3] = dice4;
578
-        cup[4] = dice5;
579
-        for (Dice d : cup) {
580
-            d.roll();
581 421
         }
582 422
 
583
-        //When
584
-        scoreSheet.setRow(ScoreSheet.ROW.SMALLSTRAIGHT, cup);
423
+        @Test
424
+        public void testSetRowThreeOfAKind () {
425
+            //Given
426
+            cup[0] = dice1;
427
+            cup[1] = dice2;
428
+            cup[2] = dice3;
429
+            cup[3] = dice4;
430
+            cup[4] = dice5;
431
+            for (Dice d : cup) {
432
+                d.roll();
433
+            }
585 434
 
435
+            //When
436
+            scoreSheet.setRow(ScoreSheet.ROW.THREEOFAKIND, cup);
586 437
 
587
-        //Then
588
-        Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.SMALLSTRAIGHT) != null));
589 438
 
590
-    }
439
+            //Then
440
+            Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.THREEOFAKIND) != null));
591 441
 
592
-    @Test
593
-    public void testSetRowLargeStraight() {
594
-        //Given
595
-        ScoreSheet scoreSheet = new ScoreSheet();
596
-        Dice dice1 = new Dice();
597
-        Dice dice2 = new Dice();
598
-        Dice dice3 = new Dice();
599
-        Dice dice4 = new Dice();
600
-        Dice dice5 = new Dice();
601
-        Dice[] cup = new Dice[5];
602
-        cup[0] = dice1;
603
-        cup[1] = dice2;
604
-        cup[2] = dice3;
605
-        cup[3] = dice4;
606
-        cup[4] = dice5;
607
-        for (Dice d : cup) {
608
-            d.roll();
609 442
         }
610 443
 
611
-        //When
612
-        scoreSheet.setRow(ScoreSheet.ROW.LARGESTRAIGHT, cup);
444
+        @Test
445
+        public void testSetRowFourOfAKind () {
446
+            //Given
447
+            cup[0] = dice1;
448
+            cup[1] = dice2;
449
+            cup[2] = dice3;
450
+            cup[3] = dice4;
451
+            cup[4] = dice5;
452
+            for (Dice d : cup) {
453
+                d.roll();
454
+            }
613 455
 
456
+            //When
457
+            scoreSheet.setRow(ScoreSheet.ROW.FOUROFAKIND, cup);
614 458
 
615
-        //Then
616
-        Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.LARGESTRAIGHT) != null));
617 459
 
618
-    }
460
+            //Then
461
+            Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.FOUROFAKIND) != null));
619 462
 
620
-    @Test
621
-    public void testSetRowYahtzee() {
622
-        //Given
623
-        ScoreSheet scoreSheet = new ScoreSheet();
624
-        Dice dice1 = new Dice();
625
-        Dice dice2 = new Dice();
626
-        Dice dice3 = new Dice();
627
-        Dice dice4 = new Dice();
628
-        Dice dice5 = new Dice();
629
-        Dice[] cup = new Dice[5];
630
-        cup[0] = dice1;
631
-        cup[1] = dice2;
632
-        cup[2] = dice3;
633
-        cup[3] = dice4;
634
-        cup[4] = dice5;
635
-        for (Dice d : cup) {
636
-            d.roll();
637 463
         }
638 464
 
639
-        //When
640
-        scoreSheet.setRow(ScoreSheet.ROW.YAHTZEE, cup);
641
-
465
+        @Test
466
+        public void testSetRowFullHouse () {
467
+            //Given
468
+            cup[0] = dice1;
469
+            cup[1] = dice2;
470
+            cup[2] = dice3;
471
+            cup[3] = dice4;
472
+            cup[4] = dice5;
473
+            for (Dice d : cup) {
474
+                d.roll();
475
+
476
+            }
477
+                //When
478
+                scoreSheet.setRow(ScoreSheet.ROW.FULLHOUSE, cup);
479
+
480
+
481
+                //Then
482
+                Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.FULLHOUSE) != null));
483
+
484
+            }
485
+
486
+            @Test
487
+            public void testSetRowSmallStraight () {
488
+                //Given
489
+                cup[0] = dice1;
490
+                cup[1] = dice2;
491
+                cup[2] = dice3;
492
+                cup[3] = dice4;
493
+                cup[4] = dice5;
494
+                for (Dice d : cup) {
495
+                    d.roll();
496
+                }
497
+
498
+                //When
499
+                scoreSheet.setRow(ScoreSheet.ROW.SMALLSTRAIGHT, cup);
500
+
501
+
502
+                //Then
503
+                Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.SMALLSTRAIGHT) != null));
504
+
505
+            }
506
+
507
+            @Test
508
+            public void testSetRowLargeStraight () {
509
+                //Given
510
+                cup[0] = dice1;
511
+                cup[1] = dice2;
512
+                cup[2] = dice3;
513
+                cup[3] = dice4;
514
+                cup[4] = dice5;
515
+                for (Dice d : cup) {
516
+                    d.roll();
517
+                }
518
+
519
+                //When
520
+                scoreSheet.setRow(ScoreSheet.ROW.LARGESTRAIGHT, cup);
521
+
522
+
523
+                //Then
524
+                Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.LARGESTRAIGHT) != null));
525
+
526
+            }
527
+
528
+            @Test
529
+            public void testSetRowYahtzee () {
530
+                //Given
531
+                cup[0] = dice1;
532
+                cup[1] = dice2;
533
+                cup[2] = dice3;
534
+                cup[3] = dice4;
535
+                cup[4] = dice5;
536
+                for (Dice d : cup) {
537
+                    d.roll();
538
+                }
539
+
540
+                //When
541
+                scoreSheet.setRow(ScoreSheet.ROW.YAHTZEE, cup);
542
+
543
+
544
+                //Then
545
+                Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.YAHTZEE) != null));
546
+
547
+            }
548
+
549
+            @Test
550
+            public void testGetSize () {
551
+                //Given
552
+                int expected = 13;
553
+
554
+                //When
555
+                int actual = ScoreSheet.getSize();
556
+
557
+                //Then
558
+                Assert.assertEquals(expected, actual);
559
+
560
+            }
561
+
562
+            @Test
563
+            public void testScoreCardToString () {
564
+                //Given
565
+                String expected = "1. Aces: Totals all Ones           ** open **\n" +
566
+                        "2. Twos: Totals all Twos           ** open **\n" +
567
+                        "3. Threes: Totals all Threes       ** open **\n" +
568
+                        "4. Fours: Totals all Fours         ** open **\n" +
569
+                        "5. Fives: Totals all Fives         ** open **\n" +
570
+                        "6. Sixes: Totals all Sixes         ** open **\n" +
571
+                        "7. 3 of a Kind                     ** open **\n" +
572
+                        "8. 4 of a Kind                     ** open **\n" +
573
+                        "9. Full House                      ** open **\n" +
574
+                        "10. Small Straight: Sequence of 4  ** open **\n" +
575
+                        "11. Large Striaght: Sequence of 5  ** open **\n" +
576
+                        "12. Yahtzee: 5 of a Kind           ** open **\n" +
577
+                        "13. Chance: Sum of Dice            ** open **\n";
642 578
 
643
-        //Then
644
-        Assert.assertTrue((scoreSheet.getScore(ScoreSheet.ROW.YAHTZEE) != null));
645
-
646
-    }
579
+                //When
580
+                String actual = scoreSheet.scoreCardToString();
581
+
582
+                //Then
583
+                Assert.assertEquals(expected, actual);
584
+
585
+            }
647 586
 
648 587
     @Test
649
-    public void testGetSize() {
588
+    public void testTotalScore () {
650 589
         //Given
651
-        int expected = 13;
590
+        int expected = 0;
652 591
 
653 592
         //When
654
-        int actual = ScoreSheet.getSize();
593
+        int actual = scoreSheet.getTotalScore();
655 594
 
656 595
         //Then
657 596
         Assert.assertEquals(expected, actual);
658 597
 
659 598
     }
599
+        }
660 600
 
661
-}