Skip to content

Instantly share code, notes, and snippets.

@jbrechtel
Last active June 19, 2017 01:34
Show Gist options
  • Save jbrechtel/4699668 to your computer and use it in GitHub Desktop.
Save jbrechtel/4699668 to your computer and use it in GitHub Desktop.
Dealing cards continued

Dealing cards to players

Using the classes built in the previous dealing cards problem, we're going to deal cards to players now.

Your program will deal cards to a user-specified number of players.

The program should ask for user input and respond to the following 3 commands

  • add_player
  • deal_cards
  • show_hands

add_player tells your program that a new player has joined. No output is necessary.

deal_cards tells your program to deal 5 cards to each player.

show_hands tells your program to show the hands of each player.

calling deal_cards multiple times means the players get 5 MORE cards each time. Their existing hands don't go away.

Given the following input

add_player
add_player
deal_cards
deal_cards
show_hands

The program should show hands for two players (Player 1 and Player 2) and each player's hand should have 10 cards and there should be no cards duplicated amongst the 20 cards printed out.

An example output from calling show_hands might look like (for only 5 cards per player hand)

Player 1 Hand
-----------------
Jack of Diamonds
3 of Clubs
4 of Clubs
8 of Spades
Ace of Spades

Player 2 Hand
-----------------
King of Hearts
Queen of Hearts
Jack of Hearts
10 of Hearts
3 of Spades
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment