-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathCard.java
More file actions
405 lines (357 loc) · 7.39 KB
/
Card.java
File metadata and controls
405 lines (357 loc) · 7.39 KB
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
package monopoly;
public class Card {
private CardType type;
private CardAction action;
private int value;
private int travel = Integer.MAX_VALUE;
private int travelTo = Integer.MAX_VALUE;
private boolean nearestRail;
private int house;
private int hotel;
private int eachPlayer;
private boolean increased;
private boolean outJailFree;
private String textA;
private String textB;
private String textC;
public Card(CardType type, int a) {
if (!type.equals(CardType.CHANCE) && !type.equals(CardType.COMMUNITY))
throw new IllegalArgumentException("Card type invalid!");
if (type.equals(CardType.CHANCE))
chance(a);
else
community(a);
}
private void community(int a) {
type = CardType.COMMUNITY;
switch (a) {
case 0:
income();
break;
case 1:
street();
break;
case 2:
inherit();
break;
case 3:
opera();
break;
case 4:
xmas();
break;
case 5:
go();
break;
case 6:
bank();
break;
case 7:
jailFree();
break;
case 8:
hospital();
break;
case 9:
services();
break;
case 10:
jail();
break;
case 11:
school();
break;
case 12:
doctor();
break;
case 13:
stock();
break;
case 14:
life();
break;
case 15:
beauty();
break;
default:
break;
}
}
private void beauty() {
action = CardAction.BANK_MONEY;
textA = "You have won second prize in a";
textB = "beauty contest!";
textC = "Collect $10";
value = 10;
}
private void life() {
action = CardAction.BANK_MONEY;
textA = "Life insurance matures";
textB = "Collect $100";
value = 100;
}
private void stock() {
action = CardAction.BANK_MONEY;
textA = "From sale of stock";
textB = "You get $45";
value = 45;
}
private void doctor() {
action = CardAction.BANK_MONEY;
textA = "Doctors Fee";
textB = "Pay $50";
value = -50;
}
private void school() {
action = CardAction.BANK_MONEY;
textA = "Pay School tax of $150";
value = -150;
}
private void jail() {
action = CardAction.MOVE_TO;
textA = "Go to Jail";
travelTo = 40;
}
private void services() {
action = CardAction.BANK_MONEY;
textA = "Receive for Services $25";
value = 25;
}
private void hospital() {
action = CardAction.BANK_MONEY;
textA = "Pay hospital $100";
value = -100;
}
private void jailFree() {
action = CardAction.OUT_JAIL;
textA = "Get out of jail free card";
outJailFree = true;
}
private void bank() {
action = CardAction.BANK_MONEY;
textA = "Bank Error in your favor";
textB = "Collect $200";
value = 200;
}
private void go() {
action = CardAction.MOVE_TO;
textA = "Advance to Go";
textB = "Collect $200";
travelTo = 0;
}
private void xmas() {
action = CardAction.BANK_MONEY;
textA = "Xmas fund matures";
textB = "Collect $100";
value = 100;
}
private void opera() {
action = CardAction.PLAYER_MONEY;
textA = "Grand Opera Opening";
textB = "collect $50 from every player";
eachPlayer = 50;
}
private void inherit() {
action = CardAction.BANK_MONEY;
textA = "You inherit $100!";
value = 100;
}
private void street() {
action = CardAction.STREET_REPAIRS;
textA = "You are assessed for street repairs";
textB = "$40 per house";
textC = "$115 per hotel";
house = -40;
hotel = -115;
}
private void income() {
action = CardAction.BANK_MONEY;
textA = "Income Tax Refund";
textB = "Collect $20";
value = 20;
}
private void chance(int a) {
type = CardType.CHANCE;
switch (a) {
case 0:
reading();
break;
case 1:
dividend();
break;
case 2:
illinois();
break;
case 3:
loan();
break;
case 4:
jailFree();
break;
case 5:
repairs();
break;
case 6:
railroad();
break;
case 7:
poor();
break;
case 8:
boardwalk();
break;
case 9:
charles();
break;
case 10:
chairman();
break;
case 11:
utility();
break;
case 12:
back();
break;
case 13:
go();
break;
case 14:
jail();
break;
case 15:
railroad();
break;
default:
break;
}
}
private void back() {
action = CardAction.MOVE;
textA = "Go back 3 spaces";
travel = -3;
increased = false;
}
private void utility() {
action = CardAction.MOVE_NEAREST;
textA = "Advance token to nearest utility";
textB = "If unowned, you may buy it from the bank";
textC = "If owned, throw the dice and pay owner a total of "
+ "10 times the amount thrown";
nearestRail = false;
increased = true;
}
private void chairman() {
action = CardAction.PLAYER_MONEY;
textA = "You have been elected chariman of";
textB = "the board";
textC = "Pay each player $50";
eachPlayer = -50;
}
private void charles() {
action = CardAction.MOVE_TO;
textA = "Advance to St. Charles Place";
travelTo = 11;
increased = false;
}
private void boardwalk() {
action = CardAction.MOVE_TO;
textA = "Take a walk on the Boardwalk";
travelTo = 39;
increased = false;
}
private void poor() {
action = CardAction.BANK_MONEY;
textA = "Pay poor tax of $15";
value = -15;
}
private void railroad() {
action = CardAction.MOVE_NEAREST;
textA = "Advance token to nearest railroad and pay the owner";
textB = "twice the rental to which he is otherwise entitled.";
textC = "If railroad is unowned, you may buy it from the bank.";
nearestRail = true;
increased = true;
}
private void repairs() {
action = CardAction.STREET_REPAIRS;
textA = "Make general repairs on all your property";
textB = "Pay $25 for each house";
textC = "Pay $100 for each hotel";
house = -25;
hotel = -100;
}
private void loan() {
action = CardAction.BANK_MONEY;
textA = "Your building and loan matures";
textB = "Collect $150";
value = 150;
}
private void illinois() {
action = CardAction.MOVE_TO;
textA = "Advance to Illinois Avenue";
travelTo = 24;
increased = false;
}
private void dividend() {
action = CardAction.BANK_MONEY;
textA = "Bank pays you dividend of $50";
value = 50;
}
private void reading() {
action = CardAction.MOVE_TO;
textA = "Take a ride on the Reading";
textB = "Railroad";
textC = "If you pass go collect $200";
travelTo = 5;
increased = false;
}
public int value() {
return value;
}
public int travel() {
return travel;
}
public int travelTo() {
return travelTo;
}
public boolean travelRail() {
return nearestRail;
}
public int house() {
return house;
}
public int hotel() {
return hotel;
}
public int eachPlayer() {
return eachPlayer;
}
public boolean increased() {
return increased;
}
public boolean outJailFree() {
return outJailFree;
}
public String textA() {
return textA;
}
public String textB() {
return textB;
}
public String textC() {
return textC;
}
public CardType type() {
return type;
}
public CardAction action() {
return action;
}
public enum CardType {
COMMUNITY, CHANCE
}
public enum CardAction {
BANK_MONEY, PLAYER_MONEY, MOVE, MOVE_TO,
MOVE_NEAREST, STREET_REPAIRS, OUT_JAIL
}
}