Parcourir la source

Backing up Scorecard changes

Lauren Green il y a 6 ans
Parent
révision
2673872c67
1 fichiers modifiés avec 60 ajouts et 6 suppressions
  1. 60
    6
      src/main/java/io/zipcoder/casino/ScoreSheet.java

+ 60
- 6
src/main/java/io/zipcoder/casino/ScoreSheet.java Voir le fichier

@@ -2,18 +2,43 @@
2 2
 
3 3
 package io.zipcoder.casino;
4 4
 
5
+import java.util.EnumMap;
5 6
 import java.util.HashMap;
6 7
 import java.util.Map;
7 8
 
8 9
 public class ScoreSheet {
9
-    private Map<String, Integer> scores = new HashMap<>();
10 10
 
11
-    ScoreSheet(){}
11
+    private enum ROW{
12
+        ACES, TWOS, THREES, FOURS, FIVES, SIXES, THREEOFAKIND, FOUROFAKIND, FULLHOUSE, SMALLSTRAIGHT, LARGESTRAIGHT, YAHTZEE, CHANCE;
13
+    }
14
+    private Map<ROW, Integer> scores = new EnumMap<>(ROW.class);
15
+
16
+    ScoreSheet(){
12 17
 
13
-    public int getScore() {
14
-        return 0;
15 18
     }
16 19
 
20
+    public int getTotalScore() {
21
+
22
+        int topTotalScore = 0;
23
+        int bottomTotalScore = 0;
24
+        int index = 0;
25
+        for(ROW r : ROW.values()) {
26
+            while (index < 6) {
27
+                topTotalScore += scores.get(r);
28
+                index++;
29
+            }
30
+            if (topTotalScore >= 63) {
31
+                topTotalScore += 35;
32
+            }
33
+            while (index >= 6) {
34
+                bottomTotalScore += scores.get(r);
35
+                index++;
36
+            }
37
+        }
38
+        return topTotalScore + bottomTotalScore;
39
+        }
40
+
41
+
17 42
     public void setScore(int score) {
18 43
 
19 44
     }
@@ -22,11 +47,40 @@ public class ScoreSheet {
22 47
 
23 48
     }
24 49
 
25
-    public void setRow(String setRow){
50
+    public void setRow(ROW row){
51
+
52
+        switch(row) {
53
+            case ACES:
54
+                break;
55
+            case TWOS:
56
+                break;
57
+            case THREES:
58
+                break;
59
+            case FOURS:
60
+                break;
61
+            case FIVES:
62
+                break;
63
+            case SIXES:
64
+                break;
65
+            case THREEOFAKIND:
66
+                break;
67
+            case FOUROFAKIND:
68
+                break;
69
+            case FULLHOUSE:
70
+                break;
71
+            case SMALLSTRAIGHT:
72
+                break;
73
+            case LARGESTRAIGHT:
74
+                break;
75
+            case YAHTZEE:
76
+                break;
77
+            case CHANCE:
78
+                break;
79
+        }
26 80
 
27 81
     }
28 82
 
29
-    public void calculateScore(String row, int value){
83
+    public void calculateScore(ROW row, int value){
30 84
 
31 85
     }
32 86
 }