You are on page 1of 3

// Maclaine Morham

//CSIS 1400
//HW4
//Version 2.1.0
public class LoopHand {
public static void main(String[] args) {
int[] deck = new int[52];
String[] suits = {"Spades", "Hearts", "Diamonds", "Clubs"};
String[] ranks = {"1", "2", "3", "4", "5", "6", "7", "8", "9",
"10", "11", "12", "13"};
String[] Rk = {" ", " ", " ", " ", " "};
String[] Vl = {" ", " ", " ", " ", " "};
String[] Pr = {" ", " ", " ", " ", " "};
int[] Ver = new int[52];
int v = 0;
// Initialize cards
for (int i = 0; i < deck.length; i++){
deck[i] = i;
Ver[i] = i;
}
// Shuffle the cards
for (int i = 0; i < deck.length; i++) {
// Generate an index randomly
int index = (int)(Math.random() * deck.length);
int temp = deck[i];
deck[i] = deck[index];
deck[index] = temp;
}
// Display the first four cards
for (int i = 0; i < 5; i++) {
String suit = suits[deck[i] / 13];
String rank = ranks[deck[i] % 13];
if (rank != "1" && rank != "11" && rank != "12" && rank !=
"13"){
System.out.println(rank
}
else if (rank == "1"){
String Rank = "Ace";
System.out.println(Rank
}
else if (rank == "11"){
String Rank = "Jack";
System.out.println(Rank
}
else if (rank == "12"){
String Rank = "Queen";
System.out.println(Rank

+ " of " + suit);

+ " of " + suit);

+ " of " + suit);

+ " of " + suit);

}
else if (rank == "13"){
String Rank = "King";
System.out.println(Rank + " of " + suit);
}
Rk[i] = rank;
Vl[i] = suit;
}
if (Vl[0] == Vl[1] && Vl[0] == Vl[2] && Vl[0] == Vl[3] && Vl[0]
== Vl[4]) {
System.out.println("FLUSH of " + Vl[0]);
}
/*if (Rk[0] == Rk[1] || Rk[0] == Rk[2] || Rk[0] == Rk[3] ||
Rk[0] == Rk[4] || Rk[3] == Rk[4] || Rk[1] == Rk[2] || Rk[1] == Rk[3]
|| Rk[1] == Rk[4] || Rk[2] == Rk[3] || Rk[2] == Rk[4]) {
System.out.println("Pair");
}*/
int y = 1;
int x = 0;
for (int i = 0; i < 3; i++) {
y = x + 1;
for (int n = x; n < 4; n++) {
if (Integer.parseInt(Rk[x]) == Integer.parseInt(Rk[y])) {
//System.out.println("Pair Detected");
if (Integer.parseInt(Rk[x]) != 1 &&
Integer.parseInt(Rk[x]) != 11 && Integer.parseInt(Rk[x]) != 12 &&
Integer.parseInt(Rk[x]) != 13){
System.out.println("Pair of " + Rk[x] +"'s");
}
else if (Integer.parseInt(Rk[x])
String Rank = "Ace";
System.out.println("Pair of "
}
else if (Integer.parseInt(Rk[x])
String Rank = "Jack";
System.out.println("Pair of "
}
else if (Integer.parseInt(Rk[x])
String Rank = "Queen";
System.out.println("Pair of "

== 1){
+ Rank +"'s");
== 11){
+ Rank +"'s");
== 12){
+ Rank +"'s");

}
else if (Integer.parseInt(Rk[x]) == 13){
String Rank = "King";
System.out.println("Pair of " + Rank +"'s");
}
//System.out.println("Pair of " + Rk[x] + "'s");
}
y++;
//System.out.println(x);
//System.out.println(y);
}
x++;
}
}
}

You might also like