Question
write this method to return a hand of cards of size n. For now, we will only call it with the number 2. public static
write this method to return a hand of cards of size n. For now, we will only call it with the number 2.
public static int[] dealHand(int n)
You need to create a local int array of size n, generate two random values for each element, but make sure that they arent equal to each other. A do-while loop might make sense here. Then return the array.
Once you have cards in your hand, you need a way to print them out to show the user, so you need two methods, one will use the other.
public static void printCard(int card)
public static void printHand(int[] hand)
You will be able to find out the rank of the card using the rank() method you already wrote, but it wont make sense to print a number from 1 to 13. String s = A23456789TJQK and the s.charAt() method will help you print a character that makes sense.
Next, you need to evaluate the hand. Write the following methods:
public static boolean isPair(int[] hand)
public static boolean isStraight(int[] hand)
public static boolean isFlush(int[] hand)
public static boolean isJackOrHigher(int[] hand)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started