Pārlūkot izejas kodu

pre merge with sim

Jonathan Hinds 6 gadus atpakaļ
vecāks
revīzija
a032213eb6

+ 4
- 1
src/main/java/io/zipcoder/casino/Casino.java Parādīt failu

75
 
75
 
76
                 case 1:
76
                 case 1:
77
                     Game yahtzee = new Yahtzee(player);
77
                     Game yahtzee = new Yahtzee(player);
78
+                    game = yahtzee;
78
                     ((Yahtzee) yahtzee).startGame();
79
                     ((Yahtzee) yahtzee).startGame();
79
                     int betAmount = console.getIntFromUser("How much would you like to bet on this game?");
80
                     int betAmount = console.getIntFromUser("How much would you like to bet on this game?");
80
                     ((Yahtzee) yahtzee).setBid(betAmount);
81
                     ((Yahtzee) yahtzee).setBid(betAmount);
81
                     ((Yahtzee) yahtzee).bet(betAmount);
82
                     ((Yahtzee) yahtzee).bet(betAmount);
82
-                    game = yahtzee;
83
                     yahtzee.startRound();
83
                     yahtzee.startRound();
84
                     Printer.printMessage("You scored " + ((Yahtzee) yahtzee).getDicePlayer().getScoreSheet().getTotalScore() + " points.");
84
                     Printer.printMessage("You scored " + ((Yahtzee) yahtzee).getDicePlayer().getScoreSheet().getTotalScore() + " points.");
85
                     ((Yahtzee) yahtzee).payout();
85
                     ((Yahtzee) yahtzee).payout();
132
     public Game getGame() {
132
     public Game getGame() {
133
         return game;
133
         return game;
134
     }
134
     }
135
+    public boolean isRunning() {
136
+        return running;
137
+    }
135
 }
138
 }

+ 3
- 0
src/main/java/io/zipcoder/casino/War.java Parādīt failu

131
                 Printer.printMessage(winner.getPlayer().getName() + " has been rewarded " + tableCards.size() + " cards.");
131
                 Printer.printMessage(winner.getPlayer().getName() + " has been rewarded " + tableCards.size() + " cards.");
132
                 winner.addDiscard(tableCards);
132
                 winner.addDiscard(tableCards);
133
                 tableCards = new ArrayList<Card>();
133
                 tableCards = new ArrayList<Card>();
134
+            }else if(input.equals("quit")){
135
+                Printer.printMessage("Thanks for playing chump!");
136
+                console.getScanner().close();
134
             } else {
137
             } else {
135
                 Printer.printMessage("Sorry, I don't understand that command.");
138
                 Printer.printMessage("Sorry, I don't understand that command.");
136
             }
139
             }

+ 0
- 11
src/main/java/io/zipcoder/casino/test.java Parādīt failu

1
-package io.zipcoder.casino;
2
-
3
-public class test {
4
-    public static void main(String[] args){
5
-        Player player = new Player("NickTest", 100);
6
-        Game stud = new Stud(10);
7
-        ((Stud) stud).addPlayers(player);
8
-        ((Stud) stud).addNpc();
9
-        stud.startGame();
10
-    }
11
-}

+ 50
- 0
src/test/java/io/zipcoder/casino/CasinoTest.java Parādīt failu

4
 import org.junit.Assert;
4
 import org.junit.Assert;
5
 import org.junit.Test;
5
 import org.junit.Test;
6
 
6
 
7
+import java.io.ByteArrayInputStream;
8
+import java.util.NoSuchElementException;
9
+import java.util.Scanner;
10
+
7
 public class CasinoTest {
11
 public class CasinoTest {
8
 
12
 
13
+    @Test
14
+    public void testYahtzee(){
15
+        String test = "1";
16
+
17
+        Casino casino = new Casino();
18
+        Console console = new Console();
19
+
20
+        casino.getConsole().setScanner(new Scanner(new ByteArrayInputStream(test.getBytes())));
21
+        try {
22
+            casino.chooseGame();
23
+        }catch(NoSuchElementException e){
24
+
25
+        }
26
+
27
+        Assert.assertTrue(casino.getGame() instanceof Yahtzee);
28
+    }
29
+
30
+    @Test
31
+    public void testGetStudPlayer(){
32
+
33
+        int num = 0;
34
+        String test = "2";
35
+        Casino casino = new Casino();
36
+        Stud stud = new Stud(10);
37
+
38
+        casino.getConsole().setScanner(new Scanner(new ByteArrayInputStream(test.getBytes())));
39
+        try {
40
+            num = casino.getStudPlayers();
41
+        }catch(NoSuchElementException e){
42
+
43
+        }
44
+        System.out.println(num);
45
+        Assert.assertTrue(num == 2);
46
+    }
47
+
48
+    @Test
49
+    public void testWar(){
50
+        Casino casino = new Casino();
51
+        String input = "jon \n 100 \n 2 \n flip";
52
+
53
+        casino.getConsole().setScanner(new Scanner(new ByteArrayInputStream(input.getBytes())));
54
+        try {
55
+            casino.getConsole().createAccount();
56
+        }catch(NoSuchElementException e){
9
 
57
 
58
+        }
59
+    }
10
 }
60
 }

+ 3
- 0
src/test/java/io/zipcoder/casino/StudTest.java Parādīt failu

4
 import org.junit.Before;
4
 import org.junit.Before;
5
 import org.junit.Test;
5
 import org.junit.Test;
6
 
6
 
7
+import java.io.ByteArrayInputStream;
7
 import java.util.ArrayList;
8
 import java.util.ArrayList;
9
+import java.util.NoSuchElementException;
10
+import java.util.Scanner;
8
 
11
 
9
 public class StudTest {
12
 public class StudTest {
10
 
13