Browse Source

Scoresheet Tests

Lauren Green 6 years ago
parent
commit
d3f172776f

+ 16
- 6
src/main/java/io/zipcoder/casino/ScoreSheet.java View File

21
     public int getTotalScore() {
21
     public int getTotalScore() {
22
 
22
 
23
         int totalScore = 0;
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
             totalScore += 35;
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
         return totalScore;
40
         return totalScore;
31
     }
41
     }
32
 
42
 
33
     public String rowToString(ROW row, String description) {
43
     public String rowToString(ROW row, String description) {
34
         String rowInfo = String.format("%-35s",description);
44
         String rowInfo = String.format("%-35s",description);
35
         if(getScore(row) != null) {
45
         if(getScore(row) != null) {
36
-            rowInfo += "\n** " + getScore(row) + " **\n";
46
+            rowInfo += "** " + getScore(row) + " **\n";
37
         } else {
47
         } else {
38
-            rowInfo += "\n** open **\n";
48
+            rowInfo += "** open **\n";
39
         }
49
         }
40
         return rowInfo;
50
         return rowInfo;
41
     }
51
     }

+ 2
- 2
src/main/java/io/zipcoder/casino/Yahtzee.java View File

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

+ 258
- 319
src/test/java/io/zipcoder/casino/ScoreSheetTest.java View File

9
 
9
 
10
 public class ScoreSheetTest {
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
     @Test
21
     @Test
13
     public void testCheckThreeOfAKindFalse() {
22
     public void testCheckThreeOfAKindFalse() {
14
         //Given
23
         //Given
15
-        ScoreSheet scoreSheet = new ScoreSheet();
16
         ArrayList<Integer> test = new ArrayList<>();
24
         ArrayList<Integer> test = new ArrayList<>();
17
         test.add(5);
25
         test.add(5);
18
         test.add(3);
26
         test.add(3);
28
     @Test
36
     @Test
29
     public void testCheckThreeOfAKindTrue() {
37
     public void testCheckThreeOfAKindTrue() {
30
         //Given
38
         //Given
31
-        ScoreSheet scoreSheet = new ScoreSheet();
32
         ArrayList<Integer> test = new ArrayList<>();
39
         ArrayList<Integer> test = new ArrayList<>();
33
         test.add(2);
40
         test.add(2);
34
         test.add(3);
41
         test.add(3);
44
     @Test
51
     @Test
45
     public void testCheckFourOfAKindFalse() {
52
     public void testCheckFourOfAKindFalse() {
46
         //Given
53
         //Given
47
-        ScoreSheet scoreSheet = new ScoreSheet();
48
         ArrayList<Integer> test = new ArrayList<>();
54
         ArrayList<Integer> test = new ArrayList<>();
49
         test.add(5);
55
         test.add(5);
50
         test.add(3);
56
         test.add(3);
60
     @Test
66
     @Test
61
     public void testCheckFourOfAKindTrue() {
67
     public void testCheckFourOfAKindTrue() {
62
         //Given
68
         //Given
63
-        ScoreSheet scoreSheet = new ScoreSheet();
64
         ArrayList<Integer> test = new ArrayList<>();
69
         ArrayList<Integer> test = new ArrayList<>();
65
         test.add(2);
70
         test.add(2);
66
         test.add(3);
71
         test.add(3);
76
     @Test
81
     @Test
77
     public void testCheckYahtzeeFalse() {
82
     public void testCheckYahtzeeFalse() {
78
         //Given
83
         //Given
79
-        ScoreSheet scoreSheet = new ScoreSheet();
80
         ArrayList<Integer> test = new ArrayList<>();
84
         ArrayList<Integer> test = new ArrayList<>();
81
         test.add(5);
85
         test.add(5);
82
         test.add(3);
86
         test.add(3);
92
     @Test
96
     @Test
93
     public void testCheckYahtzeeTrue() {
97
     public void testCheckYahtzeeTrue() {
94
         //Given
98
         //Given
95
-        ScoreSheet scoreSheet = new ScoreSheet();
96
         ArrayList<Integer> test = new ArrayList<>();
99
         ArrayList<Integer> test = new ArrayList<>();
97
         test.add(2);
100
         test.add(2);
98
         test.add(2);
101
         test.add(2);
108
     @Test
111
     @Test
109
     public void testCheckFullHouseFalse() {
112
     public void testCheckFullHouseFalse() {
110
         //Given
113
         //Given
111
-        ScoreSheet scoreSheet = new ScoreSheet();
112
         ArrayList<Integer> test = new ArrayList<>();
114
         ArrayList<Integer> test = new ArrayList<>();
113
         test.add(5);
115
         test.add(5);
114
         test.add(3);
116
         test.add(3);
124
     @Test
126
     @Test
125
     public void testCheckFullHouseTrue() {
127
     public void testCheckFullHouseTrue() {
126
         //Given
128
         //Given
127
-        ScoreSheet scoreSheet = new ScoreSheet();
128
         ArrayList<Integer> test = new ArrayList<>();
129
         ArrayList<Integer> test = new ArrayList<>();
129
         test.add(2);
130
         test.add(2);
130
         test.add(3);
131
         test.add(3);
140
     @Test
141
     @Test
141
     public void testCheckLargeStraightFalse() {
142
     public void testCheckLargeStraightFalse() {
142
         //Given
143
         //Given
143
-        ScoreSheet scoreSheet = new ScoreSheet();
144
         ArrayList<Integer> test = new ArrayList<>();
144
         ArrayList<Integer> test = new ArrayList<>();
145
         test.add(5);
145
         test.add(5);
146
         test.add(3);
146
         test.add(3);
157
     @Test
157
     @Test
158
     public void testCheckLargeStraightTrue() {
158
     public void testCheckLargeStraightTrue() {
159
         //Given
159
         //Given
160
-        ScoreSheet scoreSheet = new ScoreSheet();
161
         ArrayList<Integer> test = new ArrayList<>();
160
         ArrayList<Integer> test = new ArrayList<>();
162
         test.add(2);
161
         test.add(2);
163
         test.add(3);
162
         test.add(3);
174
     @Test
173
     @Test
175
     public void testCheckSmallStraightFalse() {
174
     public void testCheckSmallStraightFalse() {
176
         //Given
175
         //Given
177
-        ScoreSheet scoreSheet = new ScoreSheet();
178
         ArrayList<Integer> test = new ArrayList<>();
176
         ArrayList<Integer> test = new ArrayList<>();
179
         test.add(5);
177
         test.add(5);
180
         test.add(3);
178
         test.add(3);
191
     @Test
189
     @Test
192
     public void testCheckSmallStraightTrue1() {
190
     public void testCheckSmallStraightTrue1() {
193
         //Given
191
         //Given
194
-        ScoreSheet scoreSheet = new ScoreSheet();
195
         ArrayList<Integer> test = new ArrayList<>();
192
         ArrayList<Integer> test = new ArrayList<>();
196
         test.add(5);
193
         test.add(5);
197
         test.add(3);
194
         test.add(3);
208
     @Test
205
     @Test
209
     public void testCheckSmallStraightTrue2() {
206
     public void testCheckSmallStraightTrue2() {
210
         //Given
207
         //Given
211
-        ScoreSheet scoreSheet = new ScoreSheet();
212
         ArrayList<Integer> test = new ArrayList<>();
208
         ArrayList<Integer> test = new ArrayList<>();
213
         test.add(1);
209
         test.add(1);
214
         test.add(3);
210
         test.add(3);
225
     @Test
221
     @Test
226
     public void testCheckSmallStraightTrue3() {
222
     public void testCheckSmallStraightTrue3() {
227
         //Given
223
         //Given
228
-        ScoreSheet scoreSheet = new ScoreSheet();
229
         ArrayList<Integer> test = new ArrayList<>();
224
         ArrayList<Integer> test = new ArrayList<>();
230
         test.add(1);
225
         test.add(1);
231
         test.add(3);
226
         test.add(3);
242
     @Test
237
     @Test
243
     public void testScoreNumbers() {
238
     public void testScoreNumbers() {
244
         //Given
239
         //Given
245
-        ScoreSheet scoreSheet = new ScoreSheet();
246
         ArrayList<Integer> test = new ArrayList<>();
240
         ArrayList<Integer> test = new ArrayList<>();
247
         test.add(2);
241
         test.add(2);
248
         test.add(3);
242
         test.add(3);
262
     @Test
256
     @Test
263
     public void testScoreTotalDice() {
257
     public void testScoreTotalDice() {
264
         //Given
258
         //Given
265
-        ScoreSheet scoreSheet = new ScoreSheet();
266
         ArrayList<Integer> test = new ArrayList<>();
259
         ArrayList<Integer> test = new ArrayList<>();
267
         test.add(2);
260
         test.add(2);
268
         test.add(3);
261
         test.add(3);
282
     @Test
275
     @Test
283
     public void testSetRowCHANCE() {
276
     public void testSetRowCHANCE() {
284
         //Given
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
         cup[0] = dice1;
278
         cup[0] = dice1;
293
         cup[1] = dice2;
279
         cup[1] = dice2;
294
         cup[2] = dice3;
280
         cup[2] = dice3;
299
         }
285
         }
300
         int expected = dice1.getValue() + dice2.getValue() + dice3.getValue() + dice4.getValue() + dice5.getValue();
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
     @Test
587
     @Test
649
-    public void testGetSize() {
588
+    public void testTotalScore () {
650
         //Given
589
         //Given
651
-        int expected = 13;
590
+        int expected = 0;
652
 
591
 
653
         //When
592
         //When
654
-        int actual = ScoreSheet.getSize();
593
+        int actual = scoreSheet.getTotalScore();
655
 
594
 
656
         //Then
595
         //Then
657
         Assert.assertEquals(expected, actual);
596
         Assert.assertEquals(expected, actual);
658
 
597
 
659
     }
598
     }
599
+        }
660
 
600
 
661
-}