I need to make a method in my poker code in which the hierarchy is represented as integer values:
1 - High Single
2 - High Pair
3 - Two Pair
4 - Three of a Kind
5 - Straight
6 - Flush
7 - Full House
8 - Four of a Kind
9 - Straight Flush
10 - Royal Flush
The method checks your hands to determine the best set of cards. I have a piece of code here already that does some other things such as returning random integers and generating them into strings. Now I need this bestHand method to complete the program. How would you do this?
Code:
import java.util.Scanner;
public class FiveCardPoker {
static Scanner input = new Scanner(System.in);
static int coinBalance = 100;
static double coinBet = 0;
static int[][] deckCards;
private short value, suit;
static int [][]userDeck = new int [5][2];
static int [][]compDeck = new int [5][2];
static String userDeckString = "";
static String userSuitString = "";
static String compDeckString = "";
static String compSuitString = "";
public static void main(String[] args) {
// TODO Auto-generated method stub
}
public static void cardValue() {
for (int i = 0; i < 5; i++) {
int cardValue = (int)(Math.random() * (14 - 2) + 2);
userDeck[i][0] = cardValue;
compDeck[i][0] = cardValue;
}
}
public static void cardSuit() {
for (int i = 0; i < 5; i++) {
int cardSuit = (int)(Math.random() * (4 - 1) + 2);
userDeck[i][0] = cardSuit;
compDeck[i][0] = cardSuit;
}
}
public static void cardString() {
for (int i = 0; i < 5; i++) {
switch(userDeck[i][0]) {
case 1: userDeckString = ("Two"); break;
case 2: userDeckString = ("Three"); break;
case 3: userDeckString = ("Four"); break;
case 4: userDeckString = ("Five"); break;
case 5: userDeckString = ("Six"); break;
case 6: userDeckString = ("Seven"); break;
case 7: userDeckString = ("Eight"); break;
case 8: userDeckString = ("Nine"); break;
case 9: userDeckString = ("Ten"); break;
case 10: userDeckString = ("Jack"); break;
case 11: userDeckString = ("Queen"); break;
case 12: userDeckString = ("King"); break;
case 13: userDeckString = ("Ace"); break;
}
switch(userDeck[i][1]) {
case 1: userSuitString = ("Spades"); break;
case 2: userSuitString = ("Hearts"); break;
case 3: userSuitString = ("Diamonds"); break;
case 4: userSuitString = ("Clubs"); break;
}
}
for (int i = 0; i < 5; i++) {
switch(compDeck[i][0]) {
case 1: compDeckString = ("Two"); break;
case 2: compDeckString = ("Three"); break;
case 3: compDeckString = ("Four"); break;
case 4: compDeckString = ("Five"); break;
case 5: compDeckString = ("Six"); break;
case 6: compDeckString = ("Seven"); break;
case 7: compDeckString = ("Eight"); break;
case 8: compDeckString = ("Nine"); break;
case 9: compDeckString = ("Ten"); break;
case 10: compDeckString = ("Jack"); break;
case 11: compDeckString = ("Queen"); break;
case 12: compDeckString = ("King"); break;
case 13: compDeckString = ("Ace"); break;
}
switch(compDeck[i][1]) {
case 1: compSuitString = ("Spades"); break;
case 2: compSuitString = ("Hearts"); break;
case 3: compSuitString = ("Diamonds"); break;
case 4: compSuitString = ("Clubs"); break;
}
}
}
public static void bestUserHand() {
}
public static void BestCompHand() {
}
public static void updateBalance() {
do {
System.out.println("How many coins would you like to bet?");
coinBet = input.nextDouble();
if (coinBet > coinBalance || coinBalance > 25) {
System.out.println("You can only bet up to 25 coins!");
}
else if (coinBet >= 1 && coinBet <= 25) {
}
} while (coinBet < 1 || coinBet > 25);
}
}