Codingassignmenthelper | Home Codingassignmenthelper | University

Vector Assignment

Assignment :

This assignment involves a vector of vectors, in essence a 2-dimensional vector.
You will be implementing a game of Match, where pairs of symbols will be hidden in a rectangular grid. The object of the game is to find the pairs of matching symbols. The symbols will come from the ASCII character set starting with A, B, C …
When the game starts, the following directions are displayed :

Image1

After the directions are displayed, the user is prompted to enter rows and columns for the rectangular grid. The value of the product of the rows and columns must be between 16 and 64. And since there will be pairs of symbols hidden, the product must be even number.

Entries for rows and columns that do not meet those criteria will cause a re-prompt of the “Size requirement: …” message. Such re-prompting is shown is the next display :
Image1

A grid with rows of 3 and columns of 4 is rejected because the product is too small. And a 7 x 3 grid is rejected because the product is odd. No special message is produced. Just issue the same prompts as before. A 5 row by 4 column grid meets the requirement. Since the product is twenty, the numbers 1 through 20 are displayed in a 5 row x 4 column grid. Hidden beneath those twenty slots will be ten pairs of symbols randomly deposited.
The product of rows x columns could be as large as 64, requiring 32 pairs of symbols. The first 26 pairs will use A through Z. The additional six symbols should come from those that follow Z on the ASCII chart : [ \ ] ^ _ `
If the number of rows was 2 and the number of columns was 8, the following grid would be displayed :
Image1

All pictures from now on, will display a 5 row x 4 column grid.
The user is informed that he/she has 30 seconds per pair to find all the matches. With the5x4 grid, the user will have 300 seconds to match the ten pairs. It is indicated in an earlier display as You will have 5 minutes and 0 seconds to find the 10 pairs.
The game ends if the user finds all the pairs within the allotted time or if time runs out.
Sometimes the last text of one display will be repeated at the top of the next display.
Image1

The game asks the user to entire two slot numbers.
It is your job as a programmer to map slot numbers to row and column in the 2-D vector.
The program will display the symbols behind the numbered slots. If the symbols stored at those two slots are not identical, No Match is printed (as shown on the left). The revealed symbols stay in view for only 3 seconds, after which the screen is cleared by calling the “clear” macro that I have provided.
Image1

If the same symbol is stored at the two slots, the user will hear a bell (produced by ‘\a’) and see Match printed beneath the grid. Then after 3 seconds the screen will be cleared, but when the screen is next shown the matched symbols will stay on the board having replaced the slot numbers.
Re-prompts will occur with the following situations:
Image1

When an out-of-bounds slot number is entered for either first or second slot number. For example a 5x4 grid has valid slot numbers between 1 to 20. In the figure to the left, the value of 21 is invalid as the first slot number.
To Continue Click Here > Vector Assignment.pdf
Codingassignmenthelper | Home Codingassignmenthelper | Home