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

I have been given this starter python code

""" 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) 

Here is sample output

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

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

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions