Task 3 - Card game

Louise is creating a card game for two players. 

The game uses a deck of cards. There are 30 cards in a deck. Each card has one colour (red, black or yellow). Each card has a number (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) for each colour. Each card is unique. 

The 30 cards are shuffled and stored in the deck.

The rules are:

  • Player 1 takes the top card from the deck.
  • Player 2 takes the next card from the deck.
  • If both players have a card of the same colour, the player with the highest number wins.
  • If both players have cards with different colours, the winning colour is shown in the table.
  • The winner of each round keeps both cards.
  • The players keep playing until there are no cards left in the deck. 

Only authorised players are allowed to play the game. Where appropriate, input from the user should be validated.

What your program needs to do

  1. Allows two players to enter their details, which are then authenticated, to ensure that they are authorised players. 
  2. Shuffles the 30 cards in the deck. 
  3. Allows each player to take a card from the top of the deck. Play continues until there are no cards left in the deck. 
  4. Calculates the winner and allocates both cards to the winner. 
  5. Displays which player wins (the player with the most cards). 
  6. Lists all of the cards held by the winning player.
  7. Stores the name and quantity of cards of the winning player in an external file. 
  8. Displays the name and quantity of cards of the 5 players with the highest quantity of cards from the external file.