Browse Source

Merge branch 'master' of laurengreen/ZCW-OOP-Casino into working

jonathan-hinds 6 years ago
parent
commit
63e3a9df0e

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

25
     }
25
     }
26
 
26
 
27
     //use hand size to determine dealing
27
     //use hand size to determine dealing
28
-    public abstract void Deal();
28
+    public abstract void deal();
29
 
29
 
30
-    public void Shuffle(){
30
+    public void shuffle(){
31
 
31
 
32
         //shuffle the card stack
32
         //shuffle the card stack
33
 
33
 

+ 37
- 27
src/main/java/io/zipcoder/casino/Console.java View File

24
 
24
 
25
     public void chooseGame()
25
     public void chooseGame()
26
     {
26
     {
27
-        System.out.println("Please choose a game to play!");
28
-        String command = getCommand();
29
-
30
-        switch(command){
31
-
32
-            case "war":
33
-                int[] warMinMax = getMinMax();
34
-                Game war = new War(warMinMax[0], warMinMax[1], 10);
35
-                ((War) war).addPlayers(player);
36
-                war.StartGame();
37
-                break;
38
-
39
-            case "three card stud":
40
-                int[] studMinMax = getMinMax();
41
-                Game stud = new Stud(studMinMax[0], studMinMax[1], 10);
42
-                ((Stud) stud).addPlayers(player);
43
-                stud.StartGame();
44
-                break;
45
-
46
-            case "yahtzee":
47
-                Game yahtzee = new Yahtzee(player);
48
-                yahtzee.StartGame();
49
-                break;
50
-
51
-            default:
52
-                Printer.noMatchingGameName(gameLib);
53
-                break;
27
+        boolean play = true;
28
+        while(play) {
29
+            System.out.println("Please choose a game to play!");
30
+            String command = getCommand();
31
+
32
+            switch (command) {
33
+
34
+                case "war":
35
+                    int[] warMinMax = getMinMax();
36
+                    Game war = new War(warMinMax[0], warMinMax[1], 10);
37
+                    ((War) war).addPlayers(player);
38
+                    war.startGame();
39
+                    break;
40
+
41
+                case "three card stud":
42
+                    int[] studMinMax = getMinMax();
43
+                    Game stud = new Stud(studMinMax[0], studMinMax[1], 10);
44
+                    ((Stud) stud).addPlayers(player);
45
+                    stud.startGame();
46
+                    break;
47
+
48
+                case "yahtzee":
49
+                    Game yahtzee = new Yahtzee(player);
50
+                    yahtzee.startGame();
51
+                    break;
52
+
53
+                default:
54
+                    Printer.noMatchingGameName(gameLib);
55
+                    break;
56
+            }
57
+            System.out.println("Do you want to play another game? Y or N");
58
+            Scanner in = new Scanner(System.in);
59
+            String response = in.next();
60
+            if (response.equalsIgnoreCase("N")) {
61
+                play = false;
62
+            }
54
         }
63
         }
64
+
55
     }
65
     }
56
 
66
 
57
     public int getIntFromUser(){
67
     public int getIntFromUser(){

+ 11
- 0
src/main/java/io/zipcoder/casino/DicePlayer.java View File

23
         for(Dice d : cup) {
23
         for(Dice d : cup) {
24
             System.out.print(d.getValue() + " ");
24
             System.out.print(d.getValue() + " ");
25
         }
25
         }
26
+        System.out.println();
27
+    }
28
+
29
+    public Player getPlayer() {
30
+        return player;
31
+    }
32
+
33
+    public void printBalanceAtEnd() {
34
+        System.out.println("Your total balance is now: $" + getPlayer().getCurrentBalance());
26
     }
35
     }
27
 }
36
 }
37
+
38
+

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

1
 package io.zipcoder.casino;
1
 package io.zipcoder.casino;
2
 
2
 
3
 public interface Gamble {
3
 public interface Gamble {
4
-     void Bet(int betAmount);
5
-     int Payout(int payoutAmount);
4
+     void bet(int betAmount);
5
+     void payout();
6
 }
6
 }

+ 3
- 3
src/main/java/io/zipcoder/casino/Game.java View File

1
 package io.zipcoder.casino;
1
 package io.zipcoder.casino;
2
 
2
 
3
 public interface Game {
3
 public interface Game {
4
-     void Quit();
5
-     void StartGame();
6
-     void StartRound();
4
+     void quit();
5
+     void startGame();
6
+     void startRound();
7
 }
7
 }

+ 1
- 0
src/main/java/io/zipcoder/casino/Player.java View File

8
     Player(String name, int initialBalance){
8
     Player(String name, int initialBalance){
9
         this.name = name;
9
         this.name = name;
10
         this.initialBalance = initialBalance;
10
         this.initialBalance = initialBalance;
11
+        this.currentBalance = initialBalance;
11
     }
12
     }
12
 
13
 
13
     public int getInitialBalance() {
14
     public int getInitialBalance() {

+ 101
- 26
src/main/java/io/zipcoder/casino/ScoreSheet.java View File

2
 
2
 
3
 package io.zipcoder.casino;
3
 package io.zipcoder.casino;
4
 
4
 
5
+import com.sun.tools.example.debug.expr.ASCII_UCodeESC_CharStream;
6
+
5
 import java.util.*;
7
 import java.util.*;
6
 
8
 
7
 public class ScoreSheet {
9
 public class ScoreSheet {
8
 
10
 
9
-    private enum ROW{
11
+    public enum ROW{
10
         ACES, TWOS, THREES, FOURS, FIVES, SIXES, THREEOFAKIND, FOUROFAKIND, FULLHOUSE, SMALLSTRAIGHT, LARGESTRAIGHT, YAHTZEE, CHANCE;
12
         ACES, TWOS, THREES, FOURS, FIVES, SIXES, THREEOFAKIND, FOUROFAKIND, FULLHOUSE, SMALLSTRAIGHT, LARGESTRAIGHT, YAHTZEE, CHANCE;
11
     }
13
     }
12
     private Map<ROW, Integer> scores = new EnumMap<>(ROW.class);
14
     private Map<ROW, Integer> scores = new EnumMap<>(ROW.class);
15
+    private static final int size = ROW.values().length;
13
 
16
 
14
     ScoreSheet(){
17
     ScoreSheet(){
15
 
18
 
17
 
20
 
18
     public int getTotalScore() {
21
     public int getTotalScore() {
19
 
22
 
20
-        int topTotalScore = 0;
21
-        int bottomTotalScore = 0;
22
-        int index = 0;
23
-        for(ROW r : ROW.values()) {
24
-            while (index < 6) {
25
-                topTotalScore += scores.get(r);
26
-                index++;
27
-            }
28
-            if (topTotalScore >= 63) {
29
-                topTotalScore += 35;
30
-            }
31
-            while (index >= 6) {
32
-                bottomTotalScore += scores.get(r);
33
-                index++;
34
-            }
35
-        }
36
-        return topTotalScore + bottomTotalScore;
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) {
26
+            totalScore += 35;
37
         }
27
         }
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
+
30
+        return totalScore;
31
+    }
32
+
38
 
33
 
39
     public void printScoreCard(){
34
     public void printScoreCard(){
40
-        for(ROW r : ROW.values()) {
41
-            System.out.println(r + ": " + scores.get(r));
35
+        System.out.print(String.format("%-35s","1. Aces: Totals all Ones"));
36
+        if(getScore(ScoreSheet.ROW.ACES) != null) {
37
+            System.out.println("** " + getScore(ScoreSheet.ROW.ACES) + " **");
38
+        } else {
39
+            System.out.println("** open **");
42
         }
40
         }
43
-
41
+        System.out.print(String.format("%-35s","2. Twos: Totals all Twos"));
42
+        if(getScore(ScoreSheet.ROW.TWOS) != null) {
43
+            System.out.println("** " + getScore(ScoreSheet.ROW.TWOS) + " **");
44
+        } else {
45
+            System.out.println("** open **");
46
+        }
47
+        System.out.print(String.format("%-35s", "3. Threes: Totals all Threes"));
48
+        if(getScore(ScoreSheet.ROW.THREES) != null) {
49
+            System.out.println("** " + getScore(ScoreSheet.ROW.THREES) + " **");
50
+        } else {
51
+            System.out.println("** open **");
52
+        }
53
+        System.out.print(String.format("%-35s", "4. Fours: Totals all Fours"));
54
+        if(getScore(ScoreSheet.ROW.FOURS) != null) {
55
+            System.out.println("** " + getScore(ScoreSheet.ROW.FOURS) + " **");
56
+        } else {
57
+            System.out.println("** open **");
58
+        }
59
+        System.out.print(String.format("%-35s", "5. Fives: Totals all Fives"));
60
+        if(getScore(ScoreSheet.ROW.FIVES) != null) {
61
+            System.out.println("** " + getScore(ScoreSheet.ROW.FIVES) + " **");
62
+        } else {
63
+            System.out.println("** open **");
64
+        }
65
+        System.out.print(String.format("%-35s", "6. Sixes: Totals all Sixes"));
66
+        if(getScore(ScoreSheet.ROW.SIXES) != null) {
67
+            System.out.println("** " + getScore(ScoreSheet.ROW.SIXES) + " **");
68
+        } else {
69
+            System.out.println("** open **");
70
+        }
71
+        System.out.print(String.format("%-35s", "7. 3 of a Kind"));
72
+        if(getScore(ScoreSheet.ROW.THREEOFAKIND) != null) {
73
+            System.out.println("** " + getScore(ScoreSheet.ROW.THREEOFAKIND) + " **");
74
+        } else {
75
+            System.out.println("** open **");
76
+        }
77
+        System.out.print(String.format("%-35s", "8. 4 of a Kind"));
78
+        if(getScore(ScoreSheet.ROW.FOUROFAKIND) != null) {
79
+            System.out.println("** " + getScore(ScoreSheet.ROW.FOUROFAKIND) + " **");
80
+        } else {
81
+            System.out.println("** open **");
82
+        }
83
+        System.out.print(String.format("%-35s", "9. Full House"));
84
+        if(getScore(ScoreSheet.ROW.FULLHOUSE) != null) {
85
+            System.out.println("** " + getScore(ScoreSheet.ROW.FULLHOUSE) + " **");
86
+        } else {
87
+            System.out.println("** open **");
88
+        }
89
+        System.out.print(String.format("%-35s","10. Small Straight: Sequence of 4"));
90
+        if(getScore(ScoreSheet.ROW.SMALLSTRAIGHT) != null) {
91
+            System.out.println("** " + getScore(ScoreSheet.ROW.SMALLSTRAIGHT) + " **");
92
+        } else {
93
+            System.out.println("** open **");
94
+        }
95
+        System.out.print(String.format("%-35s","11. Large Striaght: Sequence of 5"));
96
+        if(getScore(ScoreSheet.ROW.LARGESTRAIGHT) != null) {
97
+            System.out.println("** " + getScore(ScoreSheet.ROW.LARGESTRAIGHT) + " **");
98
+        } else {
99
+            System.out.println("** open **");
100
+        }
101
+        System.out.print(String.format("%-35s","12. Yahtzee: 5 of a Kind "));
102
+        if(getScore(ScoreSheet.ROW.YAHTZEE) != null) {
103
+            System.out.println("** " + getScore(ScoreSheet.ROW.YAHTZEE) + " **");
104
+        } else {
105
+            System.out.println("** open **");
106
+        }
107
+        System.out.print(String.format("%-35s", "13. Chance: Sum of Dice"));
108
+        if(getScore(ScoreSheet.ROW.CHANCE) != null) {
109
+            System.out.println("** " + getScore(ScoreSheet.ROW.CHANCE) + " **");
110
+        } else {
111
+            System.out.println("** open **");
112
+        }
113
+        System.out.println();
44
     }
114
     }
45
 
115
 
46
     public void setRow(ROW row, Dice[] cup){
116
     public void setRow(ROW row, Dice[] cup){
47
 
117
 
48
-        if(scores.get(row) != null) {
49
-            System.out.println("Error, you have already filled that row");
50
-        } else {
51
             ArrayList<Integer> numbers = new ArrayList<>();
118
             ArrayList<Integer> numbers = new ArrayList<>();
52
             for (Dice d : cup) {
119
             for (Dice d : cup) {
53
                 numbers.add(d.getValue());
120
                 numbers.add(d.getValue());
121
             }
188
             }
122
         }
189
         }
123
 
190
 
124
-    }
191
+
125
 
192
 
126
     public boolean checkFullHouse(ArrayList<Integer> numbers) {
193
     public boolean checkFullHouse(ArrayList<Integer> numbers) {
127
 
194
 
180
             counts[numbers.get(i) - 1]++;
247
             counts[numbers.get(i) - 1]++;
181
 
248
 
182
         for (int i: counts) {
249
         for (int i: counts) {
183
-            if (i == numb) return true;
250
+            if (i >= numb) return true;
184
         }
251
         }
185
         return false;
252
         return false;
186
     }
253
     }
204
         }
271
         }
205
         return score;
272
         return score;
206
     }
273
     }
274
+
275
+    public static int getSize() {
276
+        return size;
277
+    }
278
+
279
+    public Integer getScore(ROW row) {
280
+        return this.scores.get(row);
281
+    }
207
 }
282
 }

+ 7
- 10
src/main/java/io/zipcoder/casino/Stud.java View File

5
         super(minBet, maxBet, ante);
5
         super(minBet, maxBet, ante);
6
     }
6
     }
7
 
7
 
8
-    public void Deal() {
8
+    public void deal() {
9
 
9
 
10
     }
10
     }
11
 
11
 
22
      * Below 3 Implemented from Gamble
22
      * Below 3 Implemented from Gamble
23
      * @param betAmount
23
      * @param betAmount
24
      */
24
      */
25
-    public void Bet(int betAmount) {
25
+    public void bet(int betAmount) {
26
 
26
 
27
     }
27
     }
28
 
28
 
29
-    public int Payout(int payoutAmount) {
30
-        return 0;
31
-    }
32
-
33
-    public void Ante(int anteAmount) {
29
+    public void payout() {
34
 
30
 
35
     }
31
     }
36
 
32
 
33
+
37
     /**
34
     /**
38
      * Below 3 Implemented from Game
35
      * Below 3 Implemented from Game
39
      */
36
      */
40
 
37
 
41
-    public void Quit() {
38
+    public void quit() {
42
 
39
 
43
     }
40
     }
44
 
41
 
45
-    public void StartGame() {
42
+    public void startGame() {
46
 
43
 
47
     }
44
     }
48
 
45
 
49
-    public void StartRound() {
46
+    public void startRound() {
50
 
47
 
51
     }
48
     }
52
 }
49
 }

+ 7
- 8
src/main/java/io/zipcoder/casino/War.java View File

33
     /**
33
     /**
34
      * Below 3 Implemented from Gamble
34
      * Below 3 Implemented from Gamble
35
      */
35
      */
36
-    public void Bet(int betAmount) {
36
+    public void bet(int betAmount) {
37
         super.changeTablePot(betAmount);
37
         super.changeTablePot(betAmount);
38
     }
38
     }
39
 
39
 
40
-    public int Payout(int payoutAmount) {
40
+    public void payout() {
41
         if(super.getWinner() != null){
41
         if(super.getWinner() != null){
42
             super.getWinner().changeBalance(super.getTablePot());
42
             super.getWinner().changeBalance(super.getTablePot());
43
         }
43
         }
44
-        return 0;
45
     }
44
     }
46
 
45
 
47
     public void payAnte() {
46
     public void payAnte() {
56
      * Below 3 Implemented from Game
55
      * Below 3 Implemented from Game
57
      */
56
      */
58
 
57
 
59
-    public void Quit() {
58
+    public void quit() {
60
 
59
 
61
     }
60
     }
62
 
61
 
63
-    public void StartGame() {
62
+    public void startGame() {
64
         Deck deck = new Deck();
63
         Deck deck = new Deck();
65
         payAnte();
64
         payAnte();
66
-        Deal();
65
+        deal();
67
     }
66
     }
68
 
67
 
69
-    public void StartRound() {
68
+    public void startRound() {
70
         //player plays a card faceup
69
         //player plays a card faceup
71
         //remove cards from player hand
70
         //remove cards from player hand
72
         //pc plays a card faceup
71
         //pc plays a card faceup
79
         //insert discard into hand facedown
78
         //insert discard into hand facedown
80
     }
79
     }
81
 
80
 
82
-    public void Deal() {
81
+    public void deal() {
83
         //while there are cards in the deck
82
         //while there are cards in the deck
84
         while(super.getDeck().size() != 0){
83
         while(super.getDeck().size() != 0){
85
             //for each player playing the game
84
             //for each player playing the game

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

1
 package io.zipcoder.casino;
1
 package io.zipcoder.casino;
2
 
2
 
3
-public class Yahtzee extends DiceGame implements Game{
3
+import java.util.ArrayList;
4
+import java.util.Scanner;
5
+
6
+public class Yahtzee extends DiceGame implements Game, Gamble {
4
 
7
 
5
-    private Dice[] cup;
6
     DicePlayer dicePlayer;
8
     DicePlayer dicePlayer;
9
+    private Scanner scanner = new Scanner(System.in);
10
+    int betAmount = 0;
7
 
11
 
8
     public Yahtzee(Player player) {
12
     public Yahtzee(Player player) {
9
         this.dicePlayer = new DicePlayer(player);
13
         this.dicePlayer = new DicePlayer(player);
10
     }
14
     }
11
 
15
 
12
-    public void compareScore(DicePlayer player1, DicePlayer player2){
13
-
14
-        player1.getScoreSheet().getTotalScore();
16
+    public int getBid() {
17
+        return betAmount;
15
     }
18
     }
16
 
19
 
17
-    public void reRoll(){
18
-
20
+    public void setBid(int bid) {
21
+        this.betAmount = bid;
19
     }
22
     }
20
 
23
 
21
-    public void stopRoll(){
22
 
24
 
23
-    }
24
-
25
-    /**
26
-     * implemented from 'Game'
27
-     */
28
-    public void Quit() {
25
+    @Override
26
+    public void quit() {
29
 
27
 
30
     }
28
     }
31
 
29
 
32
-    public void StartGame() {
30
+    public void startGame() {
33
         Dice dice1 = new Dice();
31
         Dice dice1 = new Dice();
34
         Dice dice2 = new Dice();
32
         Dice dice2 = new Dice();
35
         Dice dice3 = new Dice();
33
         Dice dice3 = new Dice();
41
         dicePlayer.getCup()[2] = dice3;
39
         dicePlayer.getCup()[2] = dice3;
42
         dicePlayer.getCup()[3] = dice4;
40
         dicePlayer.getCup()[3] = dice4;
43
         dicePlayer.getCup()[4] = dice5;
41
         dicePlayer.getCup()[4] = dice5;
42
+
43
+        System.out.println("How much would you like to bet on this game?");
44
+        int betAmount = scanner.nextInt();
45
+        setBid(betAmount);
46
+        bet(betAmount);
47
+
48
+        startRound();
49
+        System.out.println("You scored " + dicePlayer.getScoreSheet().getTotalScore() + " points.");
50
+        payout();
51
+        dicePlayer.printBalanceAtEnd();
52
+        System.out.println();
44
     }
53
     }
45
 
54
 
46
-    public void StartRound() {
47
-        for(Dice d : dicePlayer.getCup()) {
48
-            d.roll();
55
+    public void startRound() {
56
+
57
+        for (int i = 0; i < ScoreSheet.getSize(); i++) {
58
+            for (Dice d : dicePlayer.getCup()) {
59
+                d.roll();
60
+            }
61
+            System.out.println("\nYou rolled:");
62
+            dicePlayer.printCup();
63
+            System.out.println();
64
+
65
+            roundRoutine();
66
+            recordingScore();
49
         }
67
         }
50
-        dicePlayer.printCup();
51
 
68
 
52
-        //roundRoutine();
69
+    }
70
+
71
+    public void roundRoutine() {
72
+
73
+        giveOptions();
74
+        giveOptions();
53
 
75
 
54
     }
76
     }
55
 
77
 
56
-    public void roundRoutine(){
78
+    public void giveOptions() {
79
+        int choice = 0;
80
+        System.out.print("Would you like to:\n1. Roll all dice again.\n2. Roll some dice again.\n3. Stop rolling and score.\nNumber of Selection: ");
81
+
82
+        Scanner in = new Scanner(System.in);
83
+        choice = in.nextInt();
84
+
85
+        switch (choice) {
86
+            case 1:
87
+                for (Dice d : dicePlayer.getCup()) {
88
+                    d.roll();
89
+                }
90
+                System.out.println("\nYou rolled:");
91
+                dicePlayer.printCup();
92
+                System.out.println();
93
+                break;
94
+
95
+            case 2:
96
+                System.out.println("Which numbers would you like to reroll? List the numbers separated by spaces.");
97
+                Scanner in2 = new Scanner(System.in);
98
+                String diceToRoll = in2.nextLine();
99
+                reRoll(diceToRoll);
100
+                System.out.println("\nYou rolled:");
101
+                dicePlayer.printCup();
102
+                System.out.println();
103
+                break;
104
+
105
+            case 3:
106
+                break;
107
+        }
108
+    }
57
 
109
 
58
-        //ask if they want to score, or roll again?
110
+    public void reRoll(String diceToRoll) {
59
 
111
 
60
-            //roll again if requested
112
+        String[] numbersString = diceToRoll.split(" ");
113
+        ArrayList<Integer> numbers = new ArrayList<>();
114
+        for (String s : numbersString) {
115
+            numbers.add(Integer.parseInt(s));
116
+        }
61
 
117
 
62
-                //continue to roll until no more rolls are left
118
+        for (Integer i : numbers) {
119
+            for (int j = 0; j < 5; j++) {
120
+                if (i == dicePlayer.getCup()[j].getValue()) {
121
+                    dicePlayer.getCup()[j].roll();
122
+                    break;
123
+                }
124
+            }
125
+        }
126
+    }
63
 
127
 
64
-        //ask user how they would like to score
128
+    public void recordingScore() {
129
+
130
+        boolean validEntry = true;
131
+        int choice = 13;
132
+        ScoreSheet.ROW row = ScoreSheet.ROW.CHANCE;
133
+
134
+        while (validEntry) {
135
+            dicePlayer.getScoreSheet().printScoreCard();
136
+            System.out.println();
137
+            System.out.println("Which row would you like to apply your turn to on the scoresheet?.\n" +
138
+                    "Remember you can only use each row once!");
139
+            System.out.print("Row:");
140
+
141
+            Scanner scanner2 = new Scanner(System.in);
142
+            choice = scanner2.nextInt();
143
+
144
+            switch (choice) {
145
+                case 1:
146
+                    row = ScoreSheet.ROW.ACES;
147
+                    break;
148
+                case 2:
149
+                    row = ScoreSheet.ROW.TWOS;
150
+                    break;
151
+                case 3:
152
+                    row = ScoreSheet.ROW.THREES;
153
+                    break;
154
+                case 4:
155
+                    row = ScoreSheet.ROW.FOURS;
156
+                    break;
157
+                case 5:
158
+                    row = ScoreSheet.ROW.FIVES;
159
+                    break;
160
+                case 6:
161
+                    row = ScoreSheet.ROW.SIXES;
162
+                    break;
163
+                case 7:
164
+                    row = ScoreSheet.ROW.THREEOFAKIND;
165
+                    break;
166
+                case 8:
167
+                    row = ScoreSheet.ROW.FOUROFAKIND;
168
+                    break;
169
+                case 9:
170
+                    row = ScoreSheet.ROW.FULLHOUSE;
171
+                    break;
172
+                case 10:
173
+                    row = ScoreSheet.ROW.SMALLSTRAIGHT;
174
+                    break;
175
+                case 11:
176
+                    row = ScoreSheet.ROW.LARGESTRAIGHT;
177
+                    break;
178
+                case 12:
179
+                    row = ScoreSheet.ROW.YAHTZEE;
180
+                    break;
181
+                case 13:
182
+                    row = ScoreSheet.ROW.CHANCE;
183
+                    break;
184
+            }
185
+            if (dicePlayer.getScoreSheet().getScore(row) == null) {
186
+                validEntry = false;
187
+            } else {
188
+                System.out.println("Error, you have already filled that row");
189
+            }
190
+        }
65
 
191
 
66
-        //calculate the users score
192
+        dicePlayer.getScoreSheet().setRow(row, dicePlayer.getCup());
193
+        System.out.println();
194
+        dicePlayer.getScoreSheet().printScoreCard();
195
+    }
67
 
196
 
197
+    @Override
198
+    public void bet(int betAmount) {
199
+        dicePlayer.getPlayer().changeBalance(betAmount * -1);
68
     }
200
     }
69
-}
201
+
202
+    @Override
203
+    public void payout() {
204
+        int score = dicePlayer.getScoreSheet().getTotalScore();
205
+        int payOut = 0;
206
+        if (score == 1575) {
207
+            payOut = getBid() * 100;
208
+        } else if (score > 1000) {
209
+            payOut = getBid() * 20;
210
+        } else if (score > 500) {
211
+            payOut = getBid() * 10;
212
+        } else if (score > 400) {
213
+            payOut = getBid() * 5;
214
+        } else if (score > 300) {
215
+            payOut = getBid() * 3;
216
+        } else if (score > 200) {
217
+            payOut = getBid() * 2;
218
+        } else {
219
+            payOut = 0;
220
+        }
221
+        dicePlayer.getPlayer().changeBalance(payOut);
222
+        System.out.println("You won $" + payOut);
223
+    }
224
+
225
+}

+ 1
- 2
src/test/java/io/zipcoder/casino/ScoreSheetTest.java View File

3
 import org.junit.Assert;
3
 import org.junit.Assert;
4
 import org.junit.Test;
4
 import org.junit.Test;
5
 
5
 
6
-import java.lang.reflect.Array;
6
+
7
 import java.util.ArrayList;
7
 import java.util.ArrayList;
8
-import java.util.Arrays;
9
 import java.util.Collections;
8
 import java.util.Collections;
10
 
9
 
11
 public class ScoreSheetTest {
10
 public class ScoreSheetTest {