Question: You will be working on a modified version of Chapter 03_08. An implementation of the card game of War. Quick description: Two players start with

  • You will be working on a modified version of Chapter 03_08. An implementation of the card game of War.
    • Quick description:
      1. Two players start with a shuffled deck and deal the decks to each player so they start with a random assortment of 26 cards each.
      2. Each player deals a card and the player with the higher card takes both cards and places them in their hand
      3. If both players have the same cards (e.g., each have 4's), there is a WAR in which each player places three cards face down and deal a fourth card and the player with the higher card takes ALL the cards and places them in their hand
        • Note: I've modified the game so that if the cards are equal, the cards return the original players. Once you get this modified version, if you want to be challenged, implement the traditional game!
      4. Play continues until one player has no more cards to play.
      5. Winner is the player with all the cards.
  • You'll find a zipped file with four files in it:
    • Card.py
      • slightly modified in the < operator (we don't need to keep track of suits)
    • Deck.py
    • Hand.py
      • modified from what we did in class with new methods.
      • you should look to see what methods you have available as you'll need the additions
    • war.py
      • this is the file you'll be working with
  • In war.py, you'll find the need to create three functions. Instructions for what the functions should do are given IN the war.py file.
  • You do not (and should not) make any changes to any files other than war.py.
  • In war.py, you may comment out the driver portion at the bottom of the file until you are confident that your functions are working as intended then uncomment and use the main() that is there
    • DO NOT MODIFY THE DRIVER
  • I did not provide individual tests this time so you will have to use the methods in the classes to figure out whether your code is behaving correctly.
    • You should not be asking me if it is working correctly

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!