Description
Write a small program that will read in 52 cards from a file, shuffle the cards, print the unshuffled deck to the screen, and print the shuffled deck to a new file. This program is the start of building a Free Cell card game.
The unshuffled deck of cards should be represented in the program by a three-dimensional array (4 rows – 1 for each suit and 13 columns – 1 for each rank). The shuffled deck should be represented by a two-dimensional array (52 rows – 1 card per row). A menu system should be created so that a user can choose to shuffle the deck, print the unshuffled deck to screen, or write the shuffled deck to file. Do not shuffle the deck “in place” – there should be two separate arrays to hold the unshuffled and shuffled decks.
Simply:
• Create a data file containing a deck of cards (see input data file requirements below).
• Read in the cards to a deck (three-dimensional array).
• “Shuffle the deck” using a random number generator.
• Write the unshuffled deck to the screen.
• Write the shuffled deck (two-dimensional array) to a file.
The following minimum functionality and structure is required:
• Three-dimensional array to hold the unshuffled deck.
• Two-dimensional array to hold the shuffled deck.
• Each card should be represented as one string in the 2- and 3-dimensional arrays, e.g., ace diamond is one string not two.
• The ranks should be represented as an English word, not an integer, e.g. ten not 10.
• Read from file.
• Write to screen and file.
• Menu system.
• Menu run until quit option is chosen.
• No global variables or constants except row, column, string size and/or number of cards.
• Character arrays (i.e., C-style) for your strings.
• Multiple functions including reference parameters.
• No string data type or string library allowed.
• Write your own string copy function.
• No libraries except iostream and fstream: cstdlib and ctime may also be used for random number generation.
Input data file structure:
• The data file containing the unshuffled cards should be 4 rows of cards (1 suit and 13 cards of each rank per row).
• Each card in the file should be two words (e.g., four heart, three club, ace diamond, etc.).
• There should be a space between the rank and suit of each card and between each card in a row ( e.g., two heart three heart, etc.).