Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

cards.py:https://www.cse.msu.edu/~cse231/Online/Labs/Lab11/cards.py lab11b.py:https://www.cse.msu.edu/~cse231/Online/Labs/Lab11/lab11b.py strings.txt:https://www.cse.msu.edu/~cse231/Online/Labs/Lab11/strings.txt lab11.pdf:https://www.cse.msu.edu/~cse231/Online/Labs/Lab11/lab11.pdf Part B: Programming with the Class Methods Consider the program in the file named labl lb.py, which imports the module containing

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

cards.py:https://www.cse.msu.edu/~cse231/Online/Labs/Lab11/cards.py

lab11b.py:https://www.cse.msu.edu/~cse231/Online/Labs/Lab11/lab11b.py

strings.txt:https://www.cse.msu.edu/~cse231/Online/Labs/Lab11/strings.txt

lab11.pdf:https://www.cse.msu.edu/~cse231/Online/Labs/Lab11/lab11.pdf

Part B: Programming with the Class Methods Consider the program in the file named "labl lb.py", which imports the module containing the Card and Deck classes. Extend that program to play the card game named "War". Note: you may not modity the contents of "cards. py" (the Card and Deck classes) Game Rules (Simple Version) War is a two-player game which uses a standard deck of 52 cards. Suits are ignored in the game, and the cards are ordered as follows: Ace King Queen Jack 10 9 8 7 6 5 4 3 2 (Aces are the highest cards) The cards are distributed to the two players one at a time (alternating), until both players have a stack of 26 cards Each player turns over the top card on his stack (a battle). Whoever played the card with the highest rank wins the battle and adds both cards to the bottom of his stack. In the simple version, if both cards have the same rank, each player simply returns his card to the bottom of his own stack (the battle was a stalemate) Play continues until one player has all 52 cards in his stack and wins the game Programming Notes l. After dealing out the cards, your program will repeatedly process one battle. After each battle, your program will ask the user if he wishes to continue or not (make sure that simply touching the Enter key is the default and means "continue"). Stop only if "n" or "N" is entered 2. For each battle, your program will display the card played by each player, announce the result of the battle, and display each player's stack of cards. If one player wins the game as the result of the battle, your program will announce the winner and halt. 3. After cards are played they go on the bottom of the winning hand placing your card first and then the opponents card next (this is the ordering of Test1-see output below) 4. If the user chooses to quit the game after a battle, the player with the most cards will be declared the Winner 5. In the game of War, Aces are the highest-ranked cards. However, in the Card class, Aces have the lowest rank. Your program must account for this difference 6. Your program must model each player's hand as a list of cards 7. Your program will be subdivided into functions which will pass parameters and return values to communicate among the functions 8. When played with 52 cards, the game can take a long time to complete. To test your logic in a less time-consuming way, have your program deal out a much smaller number of cards (Test l below uses only five to each player)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions