Problem Description
Magpie's Fate is a simple version of multi-player card game. A
player randomly picks cards from a deck until an Ace is
found. A score is calculated by adding the values of the cards
drawn based on the
following scoring guide:
Jack of Clubs, Jack of
Spades 10 points
Jack of Diamonds, Jack of
Hearts
15 points
Queen of Clubs, Queen of
Spades 14 points
Queen of Diamonds, Queen of Hearts 18
points
King of Clubs, King of
Spades 20 points
King of Diamonds, King of
Hearts
22 points
Even non-face
cards
0
points
Odd non-face
cards
value
of card
Aces
0
points
The goal is to get as high a score as possible. This game is
pure
luck, there is no skill involved.
The computer version must keep score for up to four human
players. The
computer deals random cards until an Ace is found then calculates
that player's score. After all player's have had a turn, the
computer determines who has the high
score. (In the case where two or more players have the same score,
the winner is the lowest numbered player.)
Input
Number of players in the game.
Output
Before starting the game, display the value
of
all the cards in the deck.
Prompt the user to enter the number of
players in the game.
The value of each card (number of points).
The total score (displayed after an Ace is
entered).
The player who won and their score.
Error Handling
If an invalid number of players is entered,
issue
the prompt again. (You may assume the user will enter an integer).
The core of the program is simply a
sentinel-controlled loop which reads cards until an Ace is
encountered.
Sample
Execution
Welcome to Magpie's Fate
Here are the card values:
Ace of Clubs points 0
Ace of Spades points 0
Ace of Diamonds points 0
Ace of Hearts points 0
Two of Clubs points 0
Two of Spades points 0
Two of Diamonds points 0
Two of Hearts points 0
Three of Clubs points 3
Three of Spades points 3
Three of Diamonds points 3
Three of Hearts points 3
Four of Clubs points 0
Four of Spades points 0
Four of Diamonds points 0
Four of Hearts points 0
Five of Clubs points 5
Five of Spades points 5
Five of Diamonds points 5
Five of Hearts points 5
Six of Clubs points 0
Six of Spades points 0
Six of Diamonds points 0
Six of Hearts points 0
Seven of Clubs points 7
Seven of Spades points 7
Seven of Diamonds points 7
Seven of Hearts points 7
Eight of Clubs points 0
Eight of Spades points 0
Eight of Diamonds points 0
Eight of Hearts points 0
Nine of Clubs points 9
Nine of Spades points 9
Nine of Diamonds points 9
Nine of Hearts points 9
Ten of Clubs points 0
Ten of Spades points 0
Ten of Diamonds points 0
Ten of Hearts points 0
Jack of Clubs points 10
Jack of Spades points 10
Jack of Diamonds points 15
Jack of Hearts points 15
Queen of Clubs points 14
Queen of Spades points 14
Queen of Diamonds points 18
Queen of Hearts points 18
King of Clubs points 20
King of Spades points 20
King of Diamonds points 22
King of Hearts points 22
How many players (1-4)? 2
Player 1's turn.
The Nine of Hearts is worth: 9
The Ten of Clubs is worth: 0
The Nine of Clubs is worth: 9
The Six of Hearts is worth: 0
The Five of Diamonds is worth: 5
The Seven of Spades is worth: 7
The Jack of Hearts is worth: 15
The Queen of Spades is worth: 14
The Two of Spades is worth: 0
The Six of Spades is worth: 0
The Seven of Hearts is worth: 7
The Four of Clubs is worth: 0
The Two of Hearts is worth: 0
The Nine of Hearts is worth: 9
The Two of Hearts is worth: 0
The Eight of Hearts is worth: 0
The Queen of Diamonds is worth: 18
The Ten of Diamonds is worth: 0
The Jack of Clubs is worth: 10
The Seven of Hearts is worth: 7
Ace ends the game. Your score for this game is 110.
Player 2's turn.
The Queen of Diamonds is worth: 18
The Five of Spades is worth: 5
The Two of Hearts is worth: 0
The Seven of Diamonds is worth: 7
The Eight of Clubs is worth: 0
The Three of Clubs is worth: 3
The Two of Hearts is worth: 0
The Three of Spades is worth: 3
The Three of Clubs is worth: 3
The King of Spades is worth: 20
The King of Diamonds is worth: 22
Ace ends the game. Your score for this game is 81.
The highest score was 110. Player 1 wins.