-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPlayer.java
219 lines (96 loc) · 3.43 KB
/
Player.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
import java.util.*;
abstract class Player {
public int bet, money, betType, number, record, initalMoney, Housemoney, IDno, playerType;
public int count = 0;
public String name = "0";
public Player(int number, int ID, int initialMon, String playerName) {
name = playerName;
money = initialMon;
initalMoney = initialMon;
record = money;
IDno = ID;
playerType = number;
}
public Player(int initialMoney) {
this.initalMoney = initialMoney;
money = initialMoney;
playerType = 0;
}
public String getName() {
return name;
}
public int getBet() {
return bet;
}
public int getMoney() {
if (money == 0) {
System.out.println("Sorry you don't have any money!");
// Need to remove this player from the queue
}
return money;
}
public int playerType() {
return playerType;
}
public void makeBet(Scanner scan) {
boolean a = true;
System.out.println("Money Available: "+money);
System.out.print("How much to bet: ");
bet = scan.nextInt();
while (a) {
if (bet > money) {
System.out.print("Invalid Input! Please enter bet within your total amount: ");
bet = scan.nextInt();
a = true;
} else if (bet < Game.minBet || bet > Game.maxBet)// Need to instantiate MIN and Max
// i.e. wheel no longer contains those
{ System.out.println("Invalid Bet amount!!");
System.out.println("Please enter amount between "+Game.minBet+" to "+ Game.maxBet);
a = true;
bet = scan.nextInt();
}
else {
a = false;
}
}
money -= bet;
Game.houseMoney += bet;
Wheel.betOptions();
System.out.print("Enter the number to command for bet:");
betType = scan.nextInt();
while (betType != 1 && betType != 2 && betType != 3) {
System.out.print("Invalid Input! Please input (1,2 or 3):");
betType = scan.nextInt();
}
if (betType == Wheel.NUMBER) {
System.out.print("Enter the number to bet on:");
number = scan.nextInt();
while (number < Wheel.MIN_NUM || number > Wheel.MAX_POSITIONS) {
System.out.print("Invalid Input. Please enter number between 1 to 14:");
number = scan.nextInt();
}
}
}
public void payment() {
money = money + Wheel.payoff(bet, betType, number);
System.out.println(name + " won: " + Wheel.payoff(bet, betType, number));
if (Wheel.payoff(bet, betType, number) == 0) {
System.out.println("New Balance: " + (money));
} else {
money += bet;
System.out.println("New Balance: " + (money));
}
Game.houseMoney -= Wheel.payoff(bet, betType, number);
}
public void addTransaction(int i) {
Mainpp.gameList.get(i).transactionLines.add(new Transaction( getName(), getBet(), Wheel.payoutAmount ));
}
public void addsubMoney(int net) {
money += net;
}
public void addMoney(int mon) {
money+=mon;
count++;
}
public abstract String printPlayer();
}