Eric Foster 6 年之前
父節點
當前提交
f27b34fa7e
共有 1 個文件被更改,包括 14 次插入10 次删除
  1. 14
    10
      src/main/java/io/zipcoder/casino/Leviathan/Games/Yahtzee.java

+ 14
- 10
src/main/java/io/zipcoder/casino/Leviathan/Games/Yahtzee.java 查看文件

@@ -7,26 +7,33 @@ import java.util.*;
7 7
 public class Yahtzee extends DiceGame {
8 8
 
9 9
     Player aPlayer;
10
-    Dice diceRoller = new Dice(5);
10
+    Dice diceRoller;
11 11
     Die[] dice;
12
-    Console console = new Console();
13
-    Map<YahtzeeField, Integer> scoreSheet = new HashMap<YahtzeeField, Integer>();
12
+    Console console;
13
+    Map<YahtzeeField, Integer> scoreSheet;
14 14
 
15 15
 
16 16
     public Yahtzee(Player aPlayer) {
17 17
         this.aPlayer = aPlayer;
18
+        diceRoller = new Dice(5);
19
+        scoreSheet = new LinkedHashMap<YahtzeeField, Integer>();
18 20
         dice = diceRoller.rollAll();
19 21
     }
20 22
 
21 23
     public static void main(String[] args) {
22
-        Player aPlayer = new Player("eric", 20);
24
+        Player aPlayer = new Player("eric", 20, 18);
23 25
         Yahtzee yahtzee = new Yahtzee(aPlayer);
24 26
         yahtzee.playGame();
25 27
     }
26 28
 
29
+    //==================================================================================
30
+    // PLAY GAME METHOD
31
+    //==================================================================================
32
+
27 33
     public void playGame() {
28 34
 
29 35
         createBlankScoreSheet();
36
+        printScoreSheet();
30 37
 
31 38
         boolean scoreSheetFull = checkScoreSheetForCompletion();
32 39
 
@@ -36,7 +43,8 @@ public class Yahtzee extends DiceGame {
36 43
             rollAgainLoop();
37 44
 
38 45
             YahtzeeField fieldChoice = chooseYahtzeeField();
39
-            scoreDice(fieldChoice);
46
+            int score = scoreDice(fieldChoice);
47
+            updateScoreSheet(fieldChoice, score);
40 48
         }
41 49
 
42 50
     }
@@ -90,7 +98,7 @@ public class Yahtzee extends DiceGame {
90 98
         return YahtzeeField.ACES;
91 99
     }
92 100
 
93
-    public void scoreDice(YahtzeeField yahtzeeField) {
101
+    public int scoreDice(YahtzeeField yahtzeeField) {
94 102
         //take in field and dice array and give a score
95 103
     }
96 104
 
@@ -98,10 +106,6 @@ public class Yahtzee extends DiceGame {
98 106
         //Take in field and score and update sheet
99 107
     }
100 108
 
101
-    public void displayScoreSheet() {
102
-        //print score sheet
103
-    }
104
-
105 109
     //==================================================================================
106 110
     // ROLLING DICE METHODS
107 111
     //==================================================================================