Browse Source

Players and testing

NedRedmond 6 years ago
parent
commit
ba306ed383

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

@@ -2,12 +2,12 @@ package io.zipcoder.casino;
2 2
 
3 3
 
4 4
 public class Casino {
5
-    private Game game = Game;
5
+    private Game game;
6 6
 
7 7
     public void main() {
8 8
     }
9 9
 
10
-    public Players<Player> enterPlayers() {
10
+    public Players enterPlayers() {
11 11
         return null;
12 12
     }
13 13
 

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

@@ -8,6 +8,9 @@ package io.zipcoder.casino;
8 8
         Dice(int dieCount) {
9 9
             this.dieCount = dieCount;
10 10
         }
11
+        Dice() {
12
+            this.dieCount = 1;
13
+        }
11 14
 
12 15
         public int tossAndSum() {
13 16
             Random random = new Random();

+ 6
- 0
src/main/java/io/zipcoder/casino/Players.java View File

@@ -29,6 +29,12 @@ public class Players<Player> {
29 29
     public void addPlayer(Player player) {
30 30
         playerList.add(player);
31 31
     }
32
+    public void addPlayers(Player ... players) {
33
+        for (Player player : players) {
34
+            playerList.add(player);
35
+        }
36
+    }
37
+
32 38
 
33 39
     public void removePlayer(final Player player) {
34 40
         playerList.removeIf(Player -> Player.equals(player));

+ 39
- 0
src/test/java/io/zipcoder/casino/PlayerTest.java View File

@@ -0,0 +1,39 @@
1
+package io.zipcoder.casino;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Before;
5
+import org.junit.Test;
6
+
7
+import static org.junit.Assert.*;
8
+
9
+public class PlayerTest {
10
+
11
+    Player player;
12
+
13
+    @Before
14
+    public void setup() {
15
+        player = new Player("Test");
16
+    }
17
+
18
+    @Test
19
+    public void getName() {
20
+        Assert.assertTrue(player.getName().equals("Test"));
21
+    }
22
+
23
+    @Test
24
+    public void setName() {
25
+        player.setName("Bob");
26
+        Assert.assertTrue(player.getName().equals("Bob"));
27
+    }
28
+
29
+    @Test
30
+    public void getChipBalance() {
31
+        Assert.assertTrue(player.getChipBalance() == 500);
32
+    }
33
+
34
+    @Test
35
+    public void setChipBalance() {
36
+        player.setChipBalance(666);
37
+        Assert.assertTrue(player.getChipBalance() == 666);
38
+    }
39
+}

+ 29
- 0
src/test/java/io/zipcoder/casino/PlayersTest.java View File

@@ -0,0 +1,29 @@
1
+package io.zipcoder.casino;
2
+
3
+import org.junit.Before;
4
+import org.junit.Test;
5
+
6
+import static org.junit.Assert.*;
7
+
8
+public class PlayersTest {
9
+
10
+    Player player1 = new Player("Bobbert");
11
+    Player player2 = new Player("Nedmond");
12
+    Player player3 = new Player("Beauseph");
13
+
14
+
15
+    @Before
16
+    public void getInstance() {
17
+        Players.getInstance().addPlayers(player1,player2,player3);
18
+    }
19
+
20
+    @Test
21
+    public void addPlayer() {
22
+        for (Player player : Players.getInstance().playerList)
23
+        System.out.println(Players.getInstance().playerList);
24
+    }
25
+
26
+    @Test
27
+    public void removePlayer() {
28
+    }
29
+}