Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this project, you will: . Practice basic C++ syntax including branching structures .Write a program that calls multiple functions Manage a two-dimensional array .

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
In this project, you will: . Practice basic C++ syntax including branching structures .Write a program that calls multiple functions Manage a two-dimensional array . Use simple file input/output 2. Background The fifteen (15 or 16 puzzle) is a common sliding puzzle that you may remember from your youth. It involves a frame of numbered square tiles in random order with one tile missing. The object of the puzzle is to place the tiles in order by making sliding moves that use the empty space. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Figure 1. Solved 15 Puzzle For this effort, we are going to create a game board that the user can manipulate in order to get a board that is out of order into a correct order. Additionally, the game will indicate when the game is "solved" by putting the tiles into the correct location. The game board will be represented by a two- dimensional grid. The actual implementation of how you want to create the grid is up to your design decisions, but you must meet all requirement ICU CIUTI I points. 5 6 7 8 9 10 11 12 13 14 15 Figure 1. Solved 15 Puzzle For this effort, we are going to create a game board that the user can manipulate in order to get a board that is out of order into a correct order. Additionally, the game will indicate when the game is "solved by putting the tiles into the correct location. The game board will be represented by a two- dimensional grid. The actual implementation of how you want to create the grid is up to your design decisions, but you must meet all requirements listed below for full points. The user will be able to "slide any tile to an empty location. If the user tries to slide the tile into a location that is already populated or off of the board, the system will indicate that it is not possible. While we can make the grid of any size, we will start with a standard 4 by 4. 0 1 2 3 U 313 Figure 2. Sample Grid 3. Assignment Description Your assignment is to develop the fifteen game (using text) where the user tries to put each of the tiles into order. On each turn, the user can slide any tile adjacent to a blank into the blank location. The game continues until all fifteen tiles are in order as shown in figure 1 above. It should then prompt the user for another game. 4. Requirements: This is a list of the requirements of this application. For this project, it is up to you exactly how you want to implement it. For you to earn all the points, however, you will de lete defined 4. Requirements: This is a list of the requirements of this application. For this project, it is up to you exactly how you want to implement it. For you to earn all the points, however, you will need to meet all the defined requirements. . You must follow the coding standard as defined in the CMSC 202 coding standards (found on Blackboard under course materials). This includes comments as required. . The project must be turned in on time by the deadline listed above. . The project must be completed in C++. You may not use any libraries or data structures that we have not learned in class. These are the only libraries that you are allowed to use in this project , , , , and . You may NOT use . You should only use namespace std. . You must use a variety of functions (at least 5) including passing parameters to those functions and returning information from those functions. At least one time, an array (of any size) must be passed to a function (although you may do this more than once). . All user input must be validated. For example, if a menu allows for 1, 2, or 3 to be entered and the user enters a 4, it will re-prompt the user. However, the user is expected to always enter the correct data type. i.e. If the user is asked to enter an integer, they will. If they are asked to enter a character, they will. You do not need to worry about checking for correct data types. . You must use at least one multi-dimensional array in this project. . When the game is initially started, it should prompt the user if they want to load the "default" puzzle or a puzzle from a file. The default puzzle which can be used for initial testing should look like this: Figure 3. Default Puzzle Input files start in row 0 and iterate through the columns then move to row 1 and iterate through the columns all the way to row 4. Each line will have data for exactly one cell. There are three test puzzle files (all are solvable) named proji_testi.txt, proji_test2.txt, and proji_test3.txt. We may use different test files and the name of the file should not appear in your code at all. Figure 4. Load Order from File . On a player's turn, the player enters a row and column number. The row and column must start at 1 (unlike the values in the array itself). The board will show each of the integers (1-15) or a 0 (representing the blank). A tile may only slide into a blank. If a tile is attempted to be slid into a space that already has a value, it will not move there. Additionally, if the tile would leave the board, it will not move either. In both cases, the user should be notified of the illegal move. After each slide, the game should check to see if all 15 tiles are in order and the blank is in the bottom right hand corner. If the win condition is met, the game should indicate that the game was won and to re-prompt the user to play again. A solved board looks like this: 3 0 1 2 C20 BOB B eto Figure 5. Solved 15 Puzzle Exit and include a thank you message for the user. Exit and include a thank you message for the user. Specific coding requirements include: . Must use at least 5 different functions. . Must be able to read a puzzle in the form of a file Must use at least one multidimensional array Must pass at least one array to a function . Must not use any global variables (constants are good!) . Must use at least one switch statement. . Must use input validation (assume the data is the correct type). Must use at least one do..while loop. - Must use constants as needed. 5. Recommendations You are free to implement this with your own functions. While not required, these are some functions that you may want to include: - Start the Game - Sets up the board based on a file or makes the default scenario (with just two out of order for initial testing). . Select Tile - user chooses the row and column of the tile to slide into the blank. Swap Tile-swaps the value of the chosen tile and the blank . Check Direction - After the user chooses a tile, checks to see if any of the adjacent tiles are empty. If so, swaps them. Print the Board - used to display the entire board formatted with the row and columns visible. 6. Sample Input and Output For this project, there are three sample files: proji_testi.txt, proji_test2.txt, and proji_test3.txt and they can be copied from my directory to yours. First navigate to your project 1 directory. Then run this command: cp Here is the proji_test2.txt run. Welcome to the Fifteen Game Would you like to load a board? 1 Yes 2. No What is the file name? proji_test2.txt 11 01 21 31 41 21 11 61 71 81 31 51101 111 121 4191 131 141 151 What is the row (left) and column (top) to slide? The tile slid up 11 11 21 31 41 21 01 61 71 81 31 51 101 111 121 41 91131141151 No winner What is the row (left) and column (top) to slide? The tile slid up 11 11 21 31 41 2151617181 31 01101 111 121 41 91 131 141 151 No winner What is the row (left) and column (top) to slide? The tile slid up Iz Is 6 19 TL 18 41 01 131 141 151 No winner What is the row (left) and column (top) to slide? The tile slid left 11 11 21 31 41 2151617181 31 91101 111 121 41131 01 41151

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions