In this project, you will write a program that “deals” five random playing cards. Each card will have a sait
In this project, you will write a program that “deals” five random playing cards. Each card will have a sait (Spades, Clubs, Hearts, or Diamonds) and a value (2-10, Jack, Queen, King, or Ace). You will then display the five cards, then display whether there is a pair (two cards with the same value) as well as the highest card (with Ace being high). Again, you are just determining if any pairs exist and the highest card. Here are four sample runs of the program from the command line (Console ): *”Notice in the last runt that the 5 of Diamonds was drantn nvice. This is OK for this propect. In this program, you will meed to generate random mambers to simulate “drawing” cards, Gencrating a random number was covered in lecture and in lab during Weck 2 and in your zyBook (Section 3.1). I/ Do this once at the top of the file import java.util.”; /IDo this ence at the beginning of main Random new Random HDo this every time yeu want to draw a card Requirements / Tips: As with Project 1. Progemmumer defined abjects can NOT be used for this project. Use of additional methods IS allowed but global variables declared outside of any method are NOT allowed. You must properly pass . values between methods. Also, do NOT USF. PACKAGES in this course. Packages cause compiling /execution errors for GTAs when grading and they are not necessary for the projects assigned in this course. – To simplify grading, the output of your program must look EXACTLY like the sample run shown. This includes spacing, line feeds, spelling, capitalization, etc. – Assume several card decks are being used. As shown in the last run above, it’s OK if you deal the same card multiple times (however, if your random numbers are working properly, it shoulda’t happen often). – If the hand has multiple pairs, you only need to display one of them. – If there are no pairs, display “You have no pairs”. – I might suggest generating a random number from 0 – 3 or and wse those values to represent the 4 suits (Spades, Clubs, Hears, or Diamonds) and a random number from 2-14 to represent the card value (2-10, Jack, Queen, King, or Ace, where Jack, 12 -Oween, efc.).
Expert Answer
This solution was written by a subject matter expert. It’s designed to help students like you learn core concepts.
1st step
All steps
Answer only
Step 1/1
import java.util.Scanner;
public class PokerPokerGame {
public PokerPokerPokerGame{ }
public void check(Card[] h) {
if (isRoyalFlush(h)) { System.out.println(“YOU GOT A ROYAL FLUSH!!!!”); return; } else if (isStraightFlush(h)) { System.out.println(“YOU GOT A STRAIGHT FLUSH!!”); return; } else if (isFourOfaKind(h)) { System.out.println(“YOU GOT A FOUR OF A KIND!”); return; } else if (isFullHouse(h)) { System.out.println(“You got a Full House!!!”); return; } else if (isFlush(h)) { System.out.println(“You got a flush!!”); return; } else if (isStraight(h)) { System.out.println(“You got a straight!”); return; } else if (isThreeOfaKind(h)) { System.out.println(“You got a three of a kind!”); return; } else if (isTwoPair(h)) { System.out.println(“You got a Two Pair.”); return; } else if (isPair(h)) { System.out.println(“You got a pair.”); return; } else { // Makes sure that there if an Ace in your hand, it is considered // the high card not low card if (h[0].getValue() == 0) System.out.println(“You only got a high card: ” + h[0].toString()); else System.out.println(“You only got a high card: ” + h[4].toString()); } }
private boolean isRoyalFlush(Card[] h) {
boolean royalFlush
OR