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 their face values. 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 you play cards with a computer. For this project, we are going to focus on one suit of the deck of cards. There are only 13 cards (value: 2, ... to 10, Jack, Queen, King and Ace) in a suit. To play: (a). You first pick a suit at random from the four suits (club, diamond, heart and spade), and display the suit. (b) Then you randomly draw a card from the suit, and let computer draw a card from the same suit at random as well. (Note after a card is taken it cannot be withdrawn again). (c). display the two cards and your program compares the values of the two card to determine who wins (there cannot be a tie in this project). Note that with a suit, you can only play at most 6 games, then you have to shuffle the cards (reset the cards). (d) ask a user if he/she wants to play again. If a user chooses to play again, go back to (a). otherwise stop the game and display total number of games played and numbers you win and computer wins respectively
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 their face values. 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 you play cards with a computer. For this project, we are going to focus on one suit of the deck of cards. There are only 13 cards (value: 2, ... to 10, Jack, Queen, King and Ace) in a suit. To play:
(a). You first pick a suit at random from the four suits (club, diamond, heart and spade), and display the suit.
(b) Then you randomly draw a card from the suit, and let computer draw a card from the same suit at random as well. (Note after a card is taken it cannot be withdrawn again).
(c). display the two cards and your program compares the values of the two card to determine who wins (there cannot be a tie in this project). Note that with a suit, you can only play at most 6 games, then you have to shuffle the cards (reset the cards).
(d) ask a user if he/she wants to play again. If a user chooses to play again, go back to (a). otherwise stop the game and display total number of games played and numbers you win and computer wins respectively.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images