Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The objective of this lab is to create the beginnings for a python-based card game. We DO NOT expect a fully functioning card game. What

The objective of this lab is to create the beginnings for a python-based card game. We DO NOT expect a fully functioning card game. What we do expect is that you create a main function and various functions that will accomplish the following goals: Build a single-dimension array to keep track of the location of every card DO NOT move cards around... Just use the array to keep track of where each card is All card data is really integers - Use other arrays to translate integers to suits, ranks, and player names All cards will start in the DECK Write a function that translates a card number to a card name. HINT - look at the suitName and rankName arrays Write a function to assign a card to a given player Dealing a card involves picking a card number and assigning a new location to the corresponding element of cardLoc Write a function that displays the location of every card. (Early versions should show numeric values for the card number and location. Later versions can include string values for prettier output.) Write a function that prints the name of every card in a given hand Starter Code Please begin by copying the following code to your editor. You will not need to change my code at all, (in fact, you may not change the main code) but you will need to add several new functions to make it work correctly. """ cardGame.py basic card game framework keeps track of card locations for as many hands as needed """ from random import * NUMCARDS = 52 DECK = 0 PLAYER = 1 COMP = 2 cardLoc = [0] * NUMCARDS suitName = ("hearts", "diamonds", "spades", "clubs") rankName = ("Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King") playerName = ("deck", "player", "computer") def main(): clearDeck() for i in range(5): assignCard(PLAYER) assignCard(COMP) showDeck() showHand(PLAYER) showHand(COMP) Sample output Your program output should look something like this. (It's perfectly fine if things don't line up perfectly. It's the general structure I'm looking for.) Location of all cards # card location 0 Ace of hearts deck 1 Two of hearts computer 2 Three of hearts deck 3 Four of hearts deck 4 Five of hearts deck 5 Six of hearts player 6 Seven of hearts deck 7 Eight of hearts player 8 Nine of hearts computer 9 Ten of hearts deck 10 Jack of hearts deck 11 Queen of hearts deck 12 King of hearts deck 13 Ace of diamonds deck 14 Two of diamonds deck 15 Three of diamonds deck 16 Four of diamonds deck 17 Five of diamonds deck 18 Six of diamonds deck 19 Seven of diamonds deck 20 Eight of diamonds deck 21 Nine of diamonds deck 22 Ten of diamonds computer 23 Jack of diamonds deck 24 Queen of diamonds deck 25 King of diamonds deck 26 Ace of spades deck 27 Two of spades deck 28 Three of spades deck 29 Four of spades deck 30 Five of spades deck 31 Six of spades deck 32 Seven of spades player 33 Eight of spades deck 34 Nine of spades deck 35 Ten of spades deck 36 Jack of spades deck 37 Queen of spades deck 38 King of spades deck 39 Ace of clubs deck 40 Two of clubs deck 41 Three of clubs deck 42 Four of clubs deck 43 Five of clubs deck 44 Six of clubs deck 45 Seven of clubs deck 46 Eight of clubs deck 47 Nine of clubs computer 48 Ten of clubs computer 49 Jack of clubs player 50 Queen of clubs player 51 King of clubs deck Displaying player hand: Six of hearts Eight of hearts Seven of spades Jack of clubs Queen of clubs Displaying computer hand: Two of hearts Nine of hearts Ten of diamonds Nine of clubs Ten of clubs Hints This assignment tends to trip people up. It is not difficult to write, but I'm asking you to think in a way that may be completely unfamiliar to you. The key to this program is the way the cards are organized in computer memory, which is NOT the way they work in real life. If you search for online help on this project, I'm pretty certain you'll get advice that will confuse you more than it helps. It's no shame to be confused. I've seen this assignment on stackoverflow and reddit, and most advice on these sites is going to confuse you more than it helps. The solution I'm looking for here is much cleaner than most of the card implementations you'll find online once you understand it. Use that kind of resource for general information, but never as a tool to answer homework problems. If you have found a solution online, we have probably already seen it too, and we'll know if you turn it in. Just ask for clarification from me or your TA if you're getting lost.. (this would be a bad week to miss recitation...) Most people make this way too complicated You don't need any arrays I didn't already give you Do not use a two-dimensional array (unless you want to for the blackbelt challenge) Computer memory does not work like actual cards. You are not really moving things around. You are storing a DATABASE of card LOCATIONS. This is actually more powerful than storing cards themselves, but it's not the way humans do it

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

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

Students also viewed these Databases questions

Question

List the main advantages and disadvantages of a partnership.

Answered: 1 week ago

Question

2. What are the different types of networks?

Answered: 1 week ago