C++ programming Arrays and Enumerated Data types
GAME1103 Programming Essentials Term Assignment Purpose
Create a program which will allow a player to play the game of Concentration. This assignment will utilize all the programming techniques we have learned throughout the term in one organized, nicely styled program. Items such as data types, variables, constants, conditional control structures, repetition control structures, functions, console I/O, file I/O, enumerated types, and arrays will all play a role in this program. The programming requirements for this assignment are listed below. In order to help plan the completion of your assignment, a “Suggested Approach” is included below the requirements. Although time will be given in class to complete the assignment, you should work on it at regular intervals over time.
Programming Requirements: • Utilize a enumerated data type for the main menu of the game • Increase the board size to 10 cards, you must utilize an array for the game board and
display variables of the game o Replace the card, display and masterDisplay variables with arrays o All code associated with the variable method implementation requires modification
as well. As an example, the code where the guesses are tracked with card1 – card6 variables need to be modified to the appropriate array and indexed accordingly
o Cards must be displayed in a 2 x 5 grid layout as shown in the sample • Randomize the cards during the gameInitialization function
o Remove the hard coded 2 by 3 boards and replace them with a randomized algorithm which randomly selects a card and then randomly places it in the board twice in order to make a matching pair.
o Cards are comprised of: 2 3 4 5 6 7 8 9 0 J Q K A. We’ll use the 0 to represent 10. • Add cheat mode functionality
o When the player enters 99 as a card location, display the board with all cards face up • Add the functionality to track players names and their scores
o Request the players name before each game and record the number of attempts it took the player to solve the puzzle. Note, your program must check if the player already exists in the list of players. If it does, then use the existing player entry, if not you’ll need to add the new player to the list (array). Plan to store a maximum of 20 player scores.
o Once the game is over, update the player list with the new results • Add a menu option to display the instructions for playing the game • Add a menu option which displays the players and their score • Add a menu option which saves the player information back the file
GAME1103 Programming Essentials Term Assignment Suggest Approach:
1. Implement the enumerated data types for the menu. 2. Replacing all the card variables with a small array of 6 elements and make sure the game operates
exactly as it did with the individual card and display variables. 3. Increase the array size to 10 and adjust the relevant functions to work with a board of 10 cards.
Be sure to test that the player can enter values of 1 to 10 for the positions and the correct cards are turning over.
4. Implement the randomized game board. 5. Add the cheat mode – very useful while playing as the object is to get your program working as
opposed to playing endless games of concentration. 6. Add the ability to load the player scores from a file. 7. Add the menu function to allow the user to display the player scores. 8. Add the functionality to save out the player’s score following the end of the game. Note, if the
player name is in the list of players, only the score is updated. Do not add a player with the same name twice.
Resources: • Sample Application on Blackboard • Textbook
Course Weighting (10%)