-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainn.java
More file actions
273 lines (237 loc) · 14 KB
/
Copy pathmainn.java
File metadata and controls
273 lines (237 loc) · 14 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
import java.util.Scanner;
public class mainn {
static String printcompdes = " ";
static int playerAccount = 100000;
static int currBettingAmount = 1000;
static int moneyOnTable = 0;
static int[] sixCardsIndex = PointSystem.shuffle();
static String[] hiddenPlayerCards = {".....CARD 1...." , ".....CARD 2...." ,".....CARD 3...."};
static String[] hiddenCompCards = {".....CARD 1...." , ".....CARD 2...." ,".....CARD 3...."};
static int playerCardPoints=PointSystem.countingPlayerPoints();
static int compCardPoints=CompMind.countingCompPoints();
static int winningAmount=0;
static boolean playerWantToShow=false;
static boolean compWantToShow=false;
static Scanner sc = new Scanner(System.in);
public static void clearScreen() {
System.out.print("\033[H\033[2J");
System.out.flush();
}
public static void homePage() {
clearScreen();
System.out.println("-----------------------------------------------------------------------------------------------------");
System.out.println("| |");
System.out.println("| |");
System.out.println("| |");
System.out.println("| _______ _______ ________ _________ _________ _________ |");
System.out.println("| | | | | | | | | |");
System.out.println("| | | | | | | | | |");
System.out.println("| _____| |_______| |________| | | | |");
System.out.println("| | | | | | | | |");
System.out.println("| | | | | | | | |");
System.out.println("| _______| | | | | | ____|____ |");
System.out.println("| |");
System.out.println("| |");
System.out.println("| |");
System.out.println("| |");
System.out.println("| PLAY( P ) EXIT ( E ) |");
System.out.println("| |");
System.out.println("| |");
System.out.println("| |");
System.out.println("-----------------------------------------------------------------------------------------------------");
String s = "";
while (true) {
s = sc.next();
if (s.equals("p")) {
break;
}
if (s.equals("e")) {
break;
}
}
if (s.equals("p")) {
confirmationWindow();
}
if (s.equals("e")) {
System.exit(0);
}
}
public static void confirmationWindow() {
// confirms wheather the player wants to continue or not
String s = "";
clearScreen();
System.out.println("-----------------------------------------------------------------------------------------------------");
System.out.println("| |");
System.out.println("| |");
System.out.println("| |");
System.out.println("| _______ _______ ________ _________ _________ _________ |");
System.out.println("| | | | | | | | | |");
System.out.println("| | | | | | | | | |");
System.out.println("| _____| |_______| |________| | | | |");
System.out.println("| | | | | | | | |");
System.out.println("| | | | | | | | |");
System.out.println("| _______| | | | | | ____|____ |");
System.out.println("| |");
System.out.println("| |");
System.out.println("| YOUR CURRENT AMOUNT IS : $ "+playerAccount);
System.out.println("| |");
System.out.println("| PRESS ( C ) TO CONTINUE |");
System.out.println("| |");
System.out.println("| |");
System.out.println("| |");
System.out.println("-----------------------------------------------------------------------------------------------------");
while (true) {
s = sc.next();
if (s.equals("c")) {
setEverything();
break;
}
if (!s.equals("c")) {
System.out.println("enter a valid input ");
}
}
}
public static void table() {
CompMind cm;
clearScreen();
// pack show bet doubleBet LeaveTheTable ExitTheGame
System.out.println("------------------------------------------------------------------------------------------------------");
System.out.println("| AMOUNT : $ "+playerAccount);
System.out.println("| |");
System.out.println("| COMPUTER PLAYER |");
System.out.println("| |");
System.out.println("| "+hiddenCompCards[0]+" "+hiddenPlayerCards[0]+" |");
System.out.println("| "+hiddenCompCards[1]+" "+hiddenPlayerCards[1]+" |");
System.out.println("| "+hiddenCompCards[2]+" "+hiddenPlayerCards[2]+" |");
System.out.println("| |");
System.out.println("| "+printcompdes+" "+printDescision()+" |");
System.out.println("| |");
System.out.println("| MONEY ON THE TABLE : $ "+moneyOnTable);
System.out.println("| |");
System.out.println("| |");
System.out.println("| SHOW ( S ) BET ( B ) DOUBLE BET ( D ) SEE CARDS ( C ) |");
System.out.println("| $"+currBettingAmount+" $ "+currBettingAmount+" $ "+currBettingAmount*2+" ");
System.out.println("| LEAVE THE TABLE ( L ) EXIT THE GAME ( E ) |");
System.out.println("| |");
System.out.println("------------------------------------------------------------------------------------------------------");
}
static String input = ""; // for takeINput() and printDescision() only .
public static void takeInput() {
input = sc.next();
switch (input) {
case "b":
printDescision();
bet();
break;
case "d":
printDescision();
doubleBet();
break;
case "s":
printDescision();
show();
break;
case "l":
printDescision();
LeaveTheTable();
break;
case "e":
printDescision();
exitTheGame();
break;
case "c":
printDescision();
seeCards();
table();
takeInput();
default:
printDescision();
break;
}
// it will take input from user for every action when and only when the player
// is on the table .
}
public static void exitTheGame() {
System.exit(0);
//will exit the game
}
public static void LeaveTheTable() {
// will leave the table , losing all his bet money
setEverything();
confirmationWindow();
}
public static void show() {
moneyOnTable+=currBettingAmount;
// will show both player and comp cards , and move on to winning screen
hiddenPlayerCards[0] =PointSystem.cards[sixCardsIndex[0]][0]+" of "+PointSystem.cards[sixCardsIndex[0]][1];
hiddenPlayerCards[1] =PointSystem.cards[sixCardsIndex[1]][0]+" of "+PointSystem.cards[sixCardsIndex[1]][1];
hiddenPlayerCards[2] =PointSystem.cards[sixCardsIndex[2]][0]+" of "+PointSystem.cards[sixCardsIndex[2]][1];
hiddenCompCards[0] =PointSystem.cards[sixCardsIndex[3]][0]+" of "+PointSystem.cards[sixCardsIndex[3]][1];
hiddenCompCards[1] =PointSystem.cards[sixCardsIndex[4]][0]+" of "+PointSystem.cards[sixCardsIndex[4]][1];
hiddenCompCards[2] =PointSystem.cards[sixCardsIndex[5]][0]+" of "+PointSystem.cards[sixCardsIndex[5]][1];
}
public static void seeCards(){
hiddenPlayerCards[0] =PointSystem.cards[sixCardsIndex[0]][0]+" of "+PointSystem.cards[sixCardsIndex[0]][1];
hiddenPlayerCards[1] =PointSystem.cards[sixCardsIndex[1]][0]+" of "+PointSystem.cards[sixCardsIndex[1]][1];
hiddenPlayerCards[2] =PointSystem.cards[sixCardsIndex[2]][0]+" of "+PointSystem.cards[sixCardsIndex[2]][1];
}
public static void doubleBet() {
playerAccount-=currBettingAmount*2;
moneyOnTable+=currBettingAmount*2;
currBettingAmount = currBettingAmount*2;
// bet double amount
}
public static void bet() {
playerAccount-=currBettingAmount;
moneyOnTable+=currBettingAmount;
// bet curr amount
}
public static String printDescision() {
// it will print the descision
switch (input) {
case "c":
return " SEE YOUR CARDS ";
case "b":
return " YOU BET THE CURRENT AMOUNT ";
case "d":
return " YOU BET DOUBLE AMOUNT ";
case "s":
playerWantToShow=true;
return " YOU WANT TO SHOW ";
default:
return " please enter a vaild input ";
}
}
public static void afterRound(){
String s = "";
while (true) {
s = sc.next();
if (s.equals("c")) {
setEverything();
break;
}
if (s.equals("e")) {
System.exit(0);
}
}
}
public static void setEverything() {
input="";
currBettingAmount = 1000;
playerAccount+= winningAmount;
winningAmount=0;
moneyOnTable=0;
playerWantToShow =false;
printcompdes=" ";
compWantToShow=false;
hiddenCompCards[0]=".....CARD 1....";
hiddenCompCards[1]=".....CARD 2....";
hiddenCompCards[2]=".....CARD 3....";
hiddenPlayerCards[0]=".....CARD 1....";
hiddenPlayerCards[1]=".....CARD 2....";
hiddenPlayerCards[2]=".....CARD 3....";
sixCardsIndex= PointSystem.shuffle();
playerCardPoints =PointSystem.countingPlayerPoints();
compCardPoints = CompMind.countingCompPoints();
}
}