Question
Playing cards are used in many computer games, including versions of such classics as solitaire, hearts, and poker. Design a Card class that contains a
Playing cards are used in many computer games, including versions of such classics as solitaire, hearts, and poker. Design a Card class that contains a character data field to hold a suit (s for spades, h for hearts, d for diamonds, or c for clubs) and an integer data field for a value from 1 to 13. Include get and set methods for each field. Save the class asCard.java.
a. Write an application that randomly selects two playing cards and displays their values. Simply assign a suit to each of the cards, but generate a random number for each cards value. However, for now, you can copy the following statements to generate a random number between 1 and 13 and assign it to a variable: final int CARDS_IN_SUIT = 13; myValue = ((int)(Math.random() * 100) % CARDS_IN_SUIT + 1);
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