Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 1 You will write an implementation of a simple card game called War Details of the game's rules can be found here http://www.bicyclecards.com/how-to-play/war/ This
Question 1 You will write an implementation of a simple card game called War Details of the game's rules can be found here http://www.bicyclecards.com/how-to-play/war/ This game uses a "standard" deck of playing cards, and involves two players. Each player is dealt half ofa randomly shuffled deck (so 26 cards each). During each turn, both plavers simultaneously flip the top card of their deck. The player who flips the highest value card wins the turn, and "captures" both cards by adding them to the bottom of their deck. If both players flip over cards with the same value, then a "war" begins: each player takes the next two cards from their deck, flipping over one and leaving the second face-down. The flipped cards are compared, and the highest value of these cards determines the winner, who now takes the "war pile" (all six cards). If these are also the same value, then the war continues; both players continue drawing two cards from their deck and flipping only the first one to compare values. The ultimate winner takes all cards in the "war pile". After a war, play resumes as normal by flipping and comparing only one card each at a time Your game should use three class: Card, Deck, and Demo Card A Card object is made up of a suit (Hearts, Diamonds, Clubs, or Spades) and a rank o The ranks, in order from lowest to highest, are: 2, 3, 4, 5, 6, 7, 8,9, 10, Jack. Queen, King, Ace o So nothing beats an Ace, and a 2 doesn't beat anything The Card class should intermally track which values are valid for both the suit and for the rank, so that another class can discover the valid suit/rank values even before creating a new Card. . There should be a comparison method that determines which of two Cards has the higher rank (note that suit is irrelevant when comparing rank; the Ace of Spades is "worth" as much as an Ace of Hearts) There should be a toString method that gives a reasonable representation for the Card You may find it easier to assign numerical values internally for each of the ranks Jack, Queen, King, and Ace, but you will still want these String names used in the toString output o
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