|
@@ -18,28 +18,105 @@ public class HighLowTest {
|
18
|
18
|
}
|
19
|
19
|
|
20
|
20
|
@Test
|
21
|
|
- public void askForWager() {
|
22
|
|
- int expected = 10;
|
23
|
|
-
|
24
|
|
- int wager = 0;
|
25
|
|
- boolean flag = true;
|
26
|
|
- Console.output("Current bankroll: " + this.player.getBankroll());
|
27
|
|
- while (flag) {
|
28
|
|
- try {
|
29
|
|
- wager = 10;
|
30
|
|
- if (wager <= 0 || wager > this.player.getBankroll()) {
|
31
|
|
- Console.output("Wrong input! Try again!");
|
32
|
|
- } else {
|
33
|
|
- flag = false;
|
34
|
|
- }
|
35
|
|
- } catch(NumberFormatException e) {
|
36
|
|
- Console.output("Wrong input! Try again!");
|
37
|
|
- }
|
38
|
|
- }
|
39
|
|
- this.player.subtractFromBankroll(wager);
|
40
|
|
- int actual = wager;
|
|
21
|
+ public void checkInput1() {
|
|
22
|
+ String expected = null;
|
|
23
|
+ String[] values = {"fghA", "fgh","dsf"};
|
|
24
|
+ String actual = game.checkInput("zsdfe", values);
|
|
25
|
+ assertEquals(expected, actual);
|
|
26
|
+ }
|
|
27
|
+
|
|
28
|
+ @Test
|
|
29
|
+ public void checkInput2() {
|
|
30
|
+ String expected = "7";
|
|
31
|
+ String[] values = {"7", "6","7"};
|
|
32
|
+ String actual = game.checkInput("7", values);
|
|
33
|
+ assertEquals(expected, actual);
|
|
34
|
+ }
|
41
|
35
|
|
|
36
|
+ @Test
|
|
37
|
+ public void checkInput3() {
|
|
38
|
+ String expected = "h";
|
|
39
|
+ String[] values = {"b", "h","f"};
|
|
40
|
+ String actual = game.checkInput("H", values);
|
|
41
|
+ assertEquals(expected, actual);
|
|
42
|
+ }
|
|
43
|
+
|
|
44
|
+ @Test
|
|
45
|
+ public void checkInput4() {
|
|
46
|
+ String expected = "fgha";
|
|
47
|
+ String[] values = {"fghA", "fgh","dsf"};
|
|
48
|
+ String actual = game.checkInput("FGhA", values);
|
42
|
49
|
assertEquals(expected, actual);
|
43
|
50
|
}
|
44
|
51
|
|
|
52
|
+ @Test
|
|
53
|
+ public void checkBankrupt1() {
|
|
54
|
+ boolean expected = true;
|
|
55
|
+ boolean actual = game.checkBankrupt();
|
|
56
|
+ assertEquals(expected, actual);
|
|
57
|
+ }
|
|
58
|
+
|
|
59
|
+ @Test
|
|
60
|
+ public void checkBankrupt2() {
|
|
61
|
+ game.bet(500);
|
|
62
|
+ boolean expected = true;
|
|
63
|
+ boolean actual = game.checkBankrupt();
|
|
64
|
+ assertEquals(expected, actual);
|
|
65
|
+ }
|
|
66
|
+
|
|
67
|
+ @Test
|
|
68
|
+ public void checkBankrupt3() {
|
|
69
|
+ game.bet(500);
|
|
70
|
+ game.bet(500);
|
|
71
|
+ //boolean expected = false;
|
|
72
|
+ boolean actual = game.checkBankrupt();
|
|
73
|
+ assertEquals(false, actual);
|
|
74
|
+ }
|
|
75
|
+
|
|
76
|
+ @Test
|
|
77
|
+ public void checkBankrupt4() {
|
|
78
|
+ game.bet(1000);
|
|
79
|
+ boolean actual = game.checkBankrupt();
|
|
80
|
+ assertEquals(false, actual);
|
|
81
|
+ }
|
|
82
|
+
|
|
83
|
+ @Test
|
|
84
|
+ public void checkBankrupt5() {
|
|
85
|
+ player.subtractFromBankroll(1000);
|
|
86
|
+ boolean actual = game.checkBankrupt();
|
|
87
|
+ assertEquals(false, actual);
|
|
88
|
+ }
|
|
89
|
+
|
|
90
|
+ @Test
|
|
91
|
+ public void checkBankroll1() {
|
|
92
|
+ boolean actual = game.checkBankroll(-900);
|
|
93
|
+ assertEquals(false, actual);
|
|
94
|
+ }
|
|
95
|
+
|
|
96
|
+ @Test
|
|
97
|
+ public void checkBankroll2() {
|
|
98
|
+ boolean actual = game.checkBankroll(1100);
|
|
99
|
+ assertEquals(false, actual);
|
|
100
|
+ }
|
|
101
|
+
|
|
102
|
+ @Test
|
|
103
|
+ public void checkBankroll3() {
|
|
104
|
+ boolean actual = game.checkBankroll(900);
|
|
105
|
+ assertEquals(true, actual);
|
|
106
|
+ }
|
|
107
|
+
|
|
108
|
+ @Test
|
|
109
|
+ public void checkIfInteger1() {
|
|
110
|
+ boolean actual = game.checkIfInteger("90324");
|
|
111
|
+ assertEquals(true, actual);
|
|
112
|
+ }
|
|
113
|
+
|
|
114
|
+ @Test
|
|
115
|
+ public void checkIfInteger2() {
|
|
116
|
+ boolean actual = game.checkIfInteger("90dfg24");
|
|
117
|
+ assertEquals(false, actual);
|
|
118
|
+ }
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
45
|
122
|
}
|