Question: Cans someone help me make this print this program? Poker.Java is what I have. Card.Java is a refrence //Poker.Java public class Poker { public Poker()

Cans someone help me make this print this program? Poker.Java is what I have. Card.Java is a refrence

//Poker.Java

public class Poker { public Poker() { String path = "/Users/mike/documents.card3.txt"; // Create a hand and add in five cards from the deck.  Hand = new CardList(); for (int i=0; i<5; i++) Hand.addCard(Deck.removeCard()); } public void playGame() { Scanner stdin = new Scanner(System.in); // shows hand  System.out.println("This is your hand: "+Hand); // Imposes limits on exchange  if (numCards > 5) numCards = 5; if (numCards < 0) numCards = 0; // Creates array for cards to be exchanged  int[] exchangeList = new int[numCards]; int cardNum = 0; // Runs as long as user wants to exchange cards  while (cardNum < numCards) { System.out.println("Enter the number of the next card you want to exchange."); int val = stdin.nextInt(); if (Poker.in(exchangeList,cardNum, val)) System.out.println("Sorry, you've chosen that card already. Try again."); else { exchangeList[cardNum] = val-1; cardNum++; } } for (int i=cardNum-1; i>=0; i--) Hand.removeCard(exchangeList[i]); // Prints out final hand  System.out.println("This is the final hand" final hand: "+Hand);   // Checks if user has four of a kind  boolean FourOfAKind = false; boolean ThreeOfAKind = false; boolean Pair = false; for (String s: Card.kinds) { int matches = Hand.numMatches(s); if (matches == 4) FourOfAKind = true; else if (matches == 3) ThreeOfAKind = true; else if (matches == 2) Pair = true; } // Prints if user has full house or pairs  // Prints if user has four of a kind  if (FourOfAKind) System.out.println("You got four of a kind!"); else if (ThreeOfAKind && Pair) System.out.println("You got a full house!"); else if (ThreeOfAKind) System.out.println("You got three of a kind!"); else if (Pair == true) System.out.println("You got a pair!"); else  System.out.println("You didn't get anything"); } public static boolean in(int[] array, int length, int searchval) { for (int i=0; iif (array[i] == searchval) return true; return false; } public static void main(String[] args) { Poker game = new Poker(); game.playGame(); } } 

//Example output.

6 H 3 S 4 S 7 S 5 S Straight

How to Rank a Poker Hand  1. count the frequency of each rank and each suit in the hand 2. set hand rank to nothing 3. examine the frequencies of the ranks for the following cases  a. only one frequency is greater than 1  i. f == 2 - one pair  ii. f == 3 - three of a kind  iii. f == 4 - four of a kind  b. two frequencies are greater than 1  i. f1 == 2 and f2 == 2 - two pair  ii. f1 == 3 and f2 == 2 (or vice versa) - full house  c. all frequencies are one  i. check for all five cards in a sequence - straight 4. examine the frequencies of the suits  a. one suit occurs 5 times  i. if the rank is nothing - flush  ii. if the rank is straight - straight flush 

//Card.Java

String data; String[] pairs; Card[] deck; Card card; File file = new File(path); FileInputStream inputStream; BufferedReader rdr = null; int ix, dx; try { deck = new Card[52]; inputStream = new FileInputStream(file); rdr = new BufferedReader(new InputStreamReader(inputStream)); while (null != (data = rdr.readLine())) { pairs = data.split(" "); for (ix = 0; ix < pairs.length; ix += 2) { card = new Card(pairs[ix], pairs[ix + 1]); dx = card.deckIndex(); if (null == deck[dx]) deck[dx] = card; else System.out.println("card " + card + " is duplicated"); } } rdr.close(); for (dx = 0; dx < deck.length; ++dx) { if (null == deck[dx]) { card = Card.factory(dx); if (null != card) System.out.println("card " + card + " is missing"); else System.out.println("deck index " + dx + " is invalid"); } } } catch (IOException iox) { System.err.println(iox.getMessage()); } } 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!