-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPokerito.java
More file actions
157 lines (147 loc) · 5.32 KB
/
Pokerito.java
File metadata and controls
157 lines (147 loc) · 5.32 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
import java.util.Scanner;
public class Pokerito {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Let's play Pokerito. Type anything when you're ready.");
scan.nextLine();
System.out.println("It's like Poker, but a lot simpler\n");
System.out.println(" • There are two players, you and the computer.");
System.out.println(" • The dealer will give each player one card.");
System.out.println(" • Then, the dealer will draw five cards (the river)");
System.out.println(" • The player with the most river matches wins! ");
System.out.println(" • If the matches are equal, everyone's a winner!\n");
System.out.println(" • Ready? Type anything if you are.");
scan.nextLine();
String yourCard = randomCard();
String computerCard = randomCard();
System.out.println("Here's your card: ");
System.out.println(yourCard);
System.out.println("\nHere's the computer's card: ");
System.out.println(computerCard);
int yourMatches = 0;
int computerMatches =0;
System.out.println("Now, the dealer will draw five cards. Press enter to continue.");
for (int i = 1; i <= 5; i++) {
scan.nextLine();
String draw = randomCard();
if (yourCard.equals(draw)){
yourMatches++;
}
if (computerCard.equals(draw)) {
computerMatches++;
}
System.out.println("Card " + i + "\n");
System.out.println(draw);
}
System.out.println("Your number of matches: " + yourMatches);
System.out.println("Computer number of matches: " + computerMatches);
if (yourMatches > computerMatches) {
System.out.println("You win!");
} else if (computerMatches > yourMatches) {
System.out.println("Computer wins!");
} else {
System.out.println("Everyone wins!");
}
scan.close();
}
public static String randomCard() {
double randomNumber = Math.random() * 13;
randomNumber += 1;
switch ((int)randomNumber) {
case 1:
return " _____\n"+
" |A _ |\n"+
" | ( ) |\n"+
" |(_'_)|\n"+
" | | |\n"+
" |____V|\n";
case 2:
return " _____\n"+
" |2 |\n"+
" | o |\n"+
" | |\n"+
" | o |\n"+
" |____Z|\n";
case 3:
return" _____\n" +
" |3 |\n"+
" | o o |\n"+
" | |\n"+
" | o |\n"+
" |____E|\n";
case 4:
return " _____\n" +
" |4 |\n"+
" | o o |\n"+
" | |\n"+
" | o o |\n"+
" |____h|\n";
case 5:
return " _____ \n" +
" |5 |\n" +
" | o o |\n" +
" | o |\n" +
" | o o |\n" +
" |____S|\n";
case 6:
return " _____ \n" +
" |6 |\n" +
" | o o |\n" +
" | o o |\n" +
" | o o |\n" +
" |____6|\n";
case 7:
return
" _____ \n" +
" |7 |\n" +
" | o o |\n" +
" |o o o|\n" +
" | o o |\n" +
" |____7|\n";
case 8:
return " _____ \n" +
" |8 |\n" +
" |o o o|\n" +
" | o o |\n" +
" |o o o|\n" +
" |____8|\n";
case 9:
return " _____ \n" +
" |9 |\n" +
" |o o o|\n" +
" |o o o|\n" +
" |o o o|\n" +
" |____9|\n";
case 10:
return " _____ \n" +
" |10 o|\n" +
" |o o o|\n" +
" |o o o|\n" +
" |o o o|\n" +
" |___10|\n";
case 11:
return " _____\n" +
" |J ww|\n"+
" | o {)|\n"+
" |o o% |\n"+
" | | % |\n"+
" |__%%[|\n";
case 12:
return " _____\n" +
" |Q ww|\n"+
" | o {(|\n"+
" |o o%%|\n"+
" | |%%%|\n"+
" |_%%%O|\n";
case 13:
return " _____\n" +
" |K WW|\n"+
" | o {)|\n"+
" |o o%%|\n"+
" | |%%%|\n"+
" |_%%%>|\n";
default:
return "This shouldn't get called.";
}
}
}