Design a Card class that contains a character data field to hold a suit (s for spades,
Question:
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 a setValue() method that does not allow a Card’s value to be less than 1 or higher than 13. If the argument to setValue() is out of range, assign 1 to the Card’s value. Save the file as Card.java. Play a very simple version of the card game War. Deal two Cards—one for the computer and one for the player—and set their suits and values randomly. Determine the higher card, then display a message indicating whether the cards are equal, the computer won, or the player won. (Playing cards are considered equal when they have the same value, no matter what their suit is.) For this game, assume the Ace (value 1) is low. Make sure that the two Cards dealt are not the same Card. For example, a deck cannot contain more than one Card representing the 2 of Spades. If two Cards are created to have the same values, change the suit for one of them. Save the application as War.java.
Step by Step Answer: