Using Python 2.7 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 Hints 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 doesnotwork like actual cards. You are not moving things around. starter Code DO NOT CHANGE """ 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)
Get Free Quote!
420 Experts Online