I'm writing a program that generates 5 cards, and I need it to tell me what type of poker hand it is.
I really need help with this as soon as possible, so any suggestions that you could give me would be appreciated SO SO SO SO SO much. I saw that someone posted a very similar question, but that person got no responses.
This is my code, some of it is commented out because I wasn't sure about those parts.
public class Poker {
public static void main(String ars[]) throws IOException {
BufferedReader stdin = new BufferedReader (new InputStreamReader (System.in));
int i, temp, pos1, pos2;
int card, cardsuit, cardrank;
int deck[] = new int [52];
String suit[] = {"Hearts", "Diamonds", "Clubs", "Spades"};
String rank[] = {"Ace", "Deuce", "Trey", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"};
int hand[] = new int [7];
int temptotals[] = new int [0];
int flush[] = new int [4];
boolean swap = true, flushtest = false;
int n = 0;
// int rank[] = new int [10];
for(i = 0; i < 52; i++){
deck = i;
}
//shuffling deck
for(i = 1; i <= 2515; i++){
pos1 = (int) (Math.random() * 52);
pos2 = (int) (Math.random() * 52);
temp = deck[pos1];
deck[pos1] = deck[pos2];
deck[pos2] = temp;
}
//deal 5 cards
for(i = 0; i <= 4; i++) {
card = deck ;
cardrank = card % 13;
cardsuit = card / 13;
System.out.println ("Card # " + (i + 1) + " is a " + rank [cardrank] + " of " + suit[cardsuit]);
}
//sort hand
while (swap) {
swap = false;
for (i = 0; i < 4; i++) {
if (hand > hand ) {
temp = hand;
hand = hand;
hand = temp;
swap = true;
}
}
}
//flush test
/* for (i = 0; i < 4; i++) {
flush = 0;
}
for (i = 0; i < 7; i++) {
n = hand / 13; //suit of each card in array
flush[n]++;
// for (i = 0; i < 4; i++) { //5 cards with same suit = flush
if (flush > 4) {
flushtest = true;
System.out.print("FLUSH \n");
} else if (flush <= 4) {
flushtest = false;
System.out.print("not \n");
}*/
}
}