Bladeren bron

DicePlayer class no more print statements

Lauren Green 6 jaren geleden
bovenliggende
commit
0cd8416b06

+ 8
- 5
src/main/java/io/zipcoder/casino/DicePlayer.java Bestand weergeven

19
         return cup;
19
         return cup;
20
     }
20
     }
21
 
21
 
22
-    public void printCup() {
22
+    public String cupToString() {
23
+
24
+        String cupString = "";
25
+
23
         for(Dice d : cup) {
26
         for(Dice d : cup) {
24
-            System.out.print(d.getValue() + " ");
27
+            cupString += (d.getValue() + " ");
25
         }
28
         }
26
-        System.out.println();
29
+        return cupString;
27
     }
30
     }
28
 
31
 
29
     public Player getPlayer() {
32
     public Player getPlayer() {
30
         return player;
33
         return player;
31
     }
34
     }
32
 
35
 
33
-    public void printBalanceAtEnd() {
34
-        System.out.println("Your total balance is now: $" + getPlayer().getCurrentBalance());
36
+    public String balanceAtEnd() {
37
+        return "Your total balance is now: $" + getPlayer().getCurrentBalance();
35
     }
38
     }
36
 }
39
 }
37
 
40
 

+ 2
- 4
src/main/java/io/zipcoder/casino/Yahtzee.java Bestand weergeven

6
 public class Yahtzee extends DiceGame implements Game, Gamble {
6
 public class Yahtzee extends DiceGame implements Game, Gamble {
7
 
7
 
8
     DicePlayer dicePlayer;
8
     DicePlayer dicePlayer;
9
-    private Scanner scanner = new Scanner(System.in);
9
+    Console console = new Console();
10
     int betAmount = 0;
10
     int betAmount = 0;
11
 
11
 
12
     public Yahtzee(Player player) {
12
     public Yahtzee(Player player) {
37
 
37
 
38
     public void startGame() {
38
     public void startGame() {
39
         createGame();
39
         createGame();
40
-
41
-        System.out.println("How much would you like to bet on this game?");
42
-        int betAmount = scanner.nextInt();
40
+        int betAmount = console.getIntFromUser("How much would you like to bet on this game?");
43
         setBid(betAmount);
41
         setBid(betAmount);
44
         bet(betAmount);
42
         bet(betAmount);
45
 
43