Algorithm for card dealer

docx

School

Ball State University *

*We aren’t endorsed by this school

Course

120

Subject

Computer Science

Date

Feb 20, 2024

Type

docx

Pages

2

Uploaded by MegaTank12168

Report
Algorithm for card dealer Constants; NUMCARDS RANKNAME SUITNAME HANDS DECK PLAYER COMPUTER Main Initialize cardDB initCards() Assign five cards to player assignCard() Assign five cards to computer assignCard() Show the current deck showDeck() Show cards in player hand showHand() Show cards in computer hand showHand() initCards() No parameters Create an empty list called cardDB Assign 52 entries, all zero Return cardDB assignCard() Parameters: cardDB, hand Pick a random number 0-51 Assign hand to that numbers location (how do we make sure the same card isn't chosen twice?) No return value needed showDB() Parameter: cardDB, hand Step through all cards Print card number Print card name getCardName() Print card location No return value
showHand() Parameters: cardDB, hand Step through all cards If card is in hand Print card name No return value getCardName() Parameters: cardNum Integer divide cardNum by 13 -> suit Modulus of cardNum and 13 -> rank Use SUITNAME and RANKNAME tuples to get string name Return card name
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help