Question
A deck of cards contains 52 cards with four suits: club, diamond, heart and spade ranging in values from 2, ... to 10, Jack, Queen,
A deck of cards contains 52 cards with four suits: club, diamond, heart and spade ranging in values from 2, ... to 10, Jack, Queen, King and Ace. Ace has the highest value in the same suit. Cards can be compared using the face value. A card with higher face value is bigger than a card with lower face value. If two cards have the same face value, then the suit determines the order. Club is smaller than diamond which is smaller than heart which is smaller than spade. For example: club 2 < diamond 2 < heart 2 < spade 2 if compared.
Write an interactive Java program that allows a user to randomly draw a card from a deck of cards, displays the card (value and suit) and then the program acts as a card dealer which randomly draws a card and displays the card. Your program then compares the two cards and displays the result: you win, or you loose, it is impossible to have a tie.
Use either four arrays or one two-dimensional array to store a deck of cards.
use a method to shuffle/reset the deck of cards which resets the deck of cards to 52 cards.
use a method that randomly draws a card and returns the card it draws. keep in mind, once a card is drawn from the deck, it cannot be drawn again.
Your program first displays a message telling the user the playing instructions, calls the method to shuffle/reset the deck of cards if user wants, calls the drawing method to draw a card, then compares two cards and finally displays the result.
After one play, your program asks user if he/she wants to continue playing or shuffle the cards and start the game with a new deck.
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