Parcourir la source

Street craps is in with dice! We are working on tests!

Kate Moore il y a 6 ans
Parent
révision
369a8dc361

+ 19
- 1
src/main/java/io/zipcoder/casino/DiceGame/Craps/Craps.java Voir le fichier

@@ -23,6 +23,8 @@ public class Craps extends DiceGame implements Gamble {
23 23
     private int pointer;
24 24
 
25 25
 
26
+
27
+
26 28
     public Craps(Player player) {
27 29
         CrapsPlayers crappyPlayer = new CrapsPlayers(player);
28 30
         this.crapsPlayer = new CrapsPlayers(player);
@@ -34,6 +36,7 @@ public class Craps extends DiceGame implements Gamble {
34 36
     public void gamePlay(){
35 37
         System.out.println("What would you like to bet? Min bet is: $" + minBet);
36 38
         int amount = scanner.nextInt();
39
+        //add a try catch
37 40
         if (amount<minBet){
38 41
             System.out.println("Sorry but the minimum bet is $"+minBet);
39 42
             gamePlay();
@@ -71,12 +74,27 @@ public class Craps extends DiceGame implements Gamble {
71 74
     }
72 75
 
73 76
     public void remainingRolls() {
77
+        System.out.println("Are you ready to roll?  yes or no");
78
+        String response = scanner.next();
79
+        if(response.equalsIgnoreCase("yes")) {
80
+        } else if(response.equalsIgnoreCase("no")) {
81
+            System.out.println("would you like to exit?");
82
+            String response2 = scanner.next();
83
+            if(response2.equalsIgnoreCase("yes")){
84
+                exitTable(crapsPlayer);
85
+            } else if(response2.equalsIgnoreCase("no")){
86
+                gamePlay();
87
+            }
88
+        } else{
89
+            System.out.println("not valid");
90
+        }
74 91
         int result = rollDice();
75 92
         if (result == pointer) {
76 93
             win(crapsPlayer);
77 94
         } else if (result == 7) {
78 95
             lose(crapsPlayer);
79
-        } else remainingRolls();
96
+        } else
97
+            remainingRolls();
80 98
     }
81 99
 
82 100
     public int betAmount(int amount, Player player) {

+ 26
- 3
src/main/java/io/zipcoder/casino/DiceGame/DiceGame.java Voir le fichier

@@ -6,6 +6,16 @@ public abstract class DiceGame implements Game {
6 6
 
7 7
     private int numOfDice = 2;
8 8
     private int[] die = new int[numOfDice];
9
+    private char one = '⚀';
10
+    private char two = '⚁';
11
+    private char three = '⚂';
12
+    private char four = '⚃';
13
+    private char five = '⚄';
14
+    private char six = '⚅';
15
+
16
+    public void displayDice(){
17
+
18
+    }
9 19
 
10 20
     public int rollDice(int numOfDice) {
11 21
         int sum = 0;
@@ -13,9 +23,22 @@ public abstract class DiceGame implements Game {
13 23
         for (int i = 0; i < numOfDice; i++) {
14 24
             die[i] = (int) Math.floor((Math.random() * 6) + 1);
15 25
             sum += die[i];
16
-            System.out.println("Die #" + (i+1) + " = " + die[i]);
26
+            if (die[i] == 1) {
27
+                System.out.println(one);
28
+            } else if (die[i] == 2) {
29
+                System.out.println(two);
30
+            } else if (die[i] == 3) {
31
+                System.out.println(three);
32
+            } else if (die[i] == 4) {
33
+                System.out.println(four);
34
+            } else if (die[i] == 5) {
35
+                System.out.println(five);
36
+            } else if (die[i] == 6) {
37
+                System.out.println(six);
38
+            }
39
+
40
+
17 41
         }
18 42
         return sum;
19 43
     }
20
-
21
-}
44
+}

+ 2
- 0
src/main/java/io/zipcoder/casino/Test.java Voir le fichier

@@ -1,6 +1,8 @@
1 1
 package io.zipcoder.casino;
2 2
 
3 3
 import io.zipcoder.casino.DiceGame.Craps.Craps;
4
+import io.zipcoder.casino.DiceGame.Dice;
5
+import io.zipcoder.casino.DiceGame.DiceGame;
4 6
 
5 7
 public class Test {
6 8