Question
c++


PROGRAM DESCRIPTION: In this assignment, you will be creating a memory matching game in C++. In this game, the user will need
.You will need to declare and define a function to process a users guesses. A user will guess two positions to attempt to ma
PROGRAM DESCRIPTION: In this assignment, you will be creating a memory matching game in C++. In this game, the user will need to match up the pairs symbols A,B,C,D,E on a 4x4 array. For example, the array could be initialized like the following: In this case, X represents an empty slot. The goal is for the user to match the A to the A, the B to the B, etc, until all pairs are matched up to win the game. The user will also have a limited number of guesses, and if they do not match all of the pairs before they run out of guesses they lose the game To make the game a bit more challenging, your program will actually maintain two, 4x4 arrays. One array, the viewable array, will display which pairs the user has already matched, and will be initialized to all X's. This array will need to be updated as pairs are matched. The other array, the hidden array, will actually contain the information about where the pairs are located. The example array above represents a possible hidden array PROGRAM REQUIREMENTS: .As with all homework programs in this course, your program's output will initially display the department and course number, your name, your EUID, and your email address. This output should be performed through a function you declare and define You will need to declare and define a function to initialize the value of all slots in both arrays to X initially, and then assign the pairs of letters to random locations in the hidden array .It should have two, two-dimensional char arrays and an integer as its .It should not return a value You will need to declare and define a function to output the char value of every slot in an array in a grid format, along with the numeric headers. See the sample output for an example. . It should have a constant two-dimensional char array and an integer as its parameters .It should not return a value
.You will need to declare and define a function to process a user's guesses. A user will guess two positions to attempt to match a letter pair. After each guess, you should inform the user what symbol was at the guessed position. The function should have two, two-dimensional char arrays and an integer as its .It should return a bool The function should prompt the user for two sets of x and y coordinates within the bounds of the array If the e user guesses a position that is outside forfeited their match attempt, should be informed of this, and the function should return false of the game area, then the user has If either guess discovered an X, then the user has failed in their match attempt, If both guesses do not result in a match, then the user has failed in their match If both guesses result in a match, then the user has succeeded in their match should be informed of this, and the function should return false. attempt, should be informed of this, and the function should return false. attempt, should be informed of this, and the function should return true. Additionally, the matched letter pair should be revealed on the visible array .Inside your main function you will need to Create two 4x4 char arrays, h letter pairs, and one visible array to display the current pairs discovered. Create a constant integer SIZE, initialized to 4, which represents the dimension of the arrays. Initialize both of the char arrays using the appropriate function. Using an appropriate loop, you should allow the user 10 attempts to match the letter pairs. one hidden array to store the positions of all of the that have been Each attempted match should use the appropriate function *After each successful or failed match, the visible array should be output to As soon as the user succeeds in matching all of the letters, they win the *If the user fails to match all of the letters in 10 tries, they lose the game. the user via the appropriate f unction. game .At the end of the game, the user should be informed whether they won or lost, and the hidden board should be displayed via the appropriate function. Your code should be well documented in terms of comments. For example, good comments in general consist of a header (with your name, course section, date, and brief description), comments for each variable, and commented blocks of code. This means, that in addition to the program printing your information to the terminal, also appear in the code in the comments as well .
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hello i'm providing the code to you for this game also you can add the function for your details and other things also you can add comment by understanding the code . code is readable and understandable Thank you

EDIT1: as you have mentiioned output format is not correct maybe you are asking for initial details so i'm attaching that function too i hope it helps if not please mention that in comment. Also in question it is mentioned that you have sample output but you have not attached that so maybe you can attach that . Give positive feedback if it helps Thankyou

#include<iostream>
#include<time.h>
using namespace std;
void initialise(char hidden[][4],char view[][4],int size)
{
srand(time(NULL));
char arr[]={'A','B','C','D','E','A','B','C','D','E'};
int pos[16]={0};
int count=0;
while(count<10)
{
int r=rand()%16;
if(pos[r]==0)
{
hidden[r/4][r%4]=arr[count++];
pos[r]=1;
}
}
for(int i=0;i<16;i++)
{
if(pos[i]==0)
hidden[i/4][i%4]='X';
}
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
view[i][j]='X';
}
}
}

void print(char hidden[][4],char view[][4],int size)
{
cout<<"\ncurrent position of the grid is:";
cout<<"\n ";
for(int i=0;i<4;i++)
{
if(i==0)
{
for(int j=1;j<5;j++)
cout<<j<<" ";
cout<<"\n";
}
cout<<i+1<<" ";
for(int j=0;j<4;j++)
{
cout<<view[i][j]<<" ";
}
cout<<"\n";
}
}
bool Match(char hidden[][4],char view[][4],int size)
{
int x1,x2,y1,y2;
  
cout<<"\nenter first position row coordinate x1:";
cin>>x1;
cout<<"\nenter first position column coordinate y1:";
cin>>y1;

cout<<"\nenter second position row coordinate x2:";
cin>>x2;
cout<<"\nenter second position column coordinate y2:";
cin>>y2;
if(x1<1 || x1>4 || y1<1 || y1>4 ||x2<1 || x2>4 || y2<1 || y2>4 )
{
cout<<"\nsorry you have wasted your attempt by invalid position";
return false;
}
else
{
cout<<"\nthe symbol at first position is:"<<hidden[x1-1][y1-1];
cout<<"\nthe symbol at seconde position is:"<<hidden[x2-1][y2-1];
if(hidden[x1-1][y1-1]=='X' || hidden[x2-1][y2-1]=='X')
cout<<"\nsorry one of your symbol is empty";
else if(hidden[x1-1][y1-1]!=hidden[x2-1][y2-1])
cout<<"\nsorry your input does not match";
else
{
cout<<"\nvoila you have matched the pair";
view[x1-1][y1-1]=hidden[x1-1][y1-1];
view[x2-1][y2-1]=hidden[x2-1][y2-1];
return true;
}
return false;   
}
}

void details()

{

cout<<"\nName:"<<"your name";

cout<<"\n Course section"<<"your course section";

cout<<"\n date:"<<"enter date";

cout<<"\n Description:"<<"enter your description";

}
int main()
{
const int size=4;
char hidden[4][4],view[4][4];
initialise(hidden,view,4);

details();
print(hidden,view,4);
int count=0;
cout<<"\n you will get 10 chances to match 5 pairs";
for(int i=1;i<11;i++)
{
if(count==5)
break;
cout<<"\nthis is your attempt no.:"<<i;
bool var=Match(hidden,view,4);
if(var)
count++;
print(hidden,view,4);
  
}
if(count==5)
cout<<"\ncongratulations you have won the game";
else
cout<<"\nsorry but you failed so try again";

}

Add a comment
Know the answer?
Add Answer to:
PROGRAM DESCRIPTION: In this assignment, you will be creating a memory matching game in C++. In t...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Word Guessing Game Assignment Help Needed. This C++ (I'm using Visual Studio 2015) assignment is actually...

    Word Guessing Game Assignment Help Needed. This C++ (I'm using Visual Studio 2015) assignment is actually kind of confusing to me. I keep getting lost in all of the words even though these are supposed to instruct me as to how to do this. Can I please get some help as to where to start? Word guessing game: Overview: Create a game in which the user has a set number of tries to correctly guess a word. I highly recommend...

  • For a C program hangman game: Create the function int play_game [play_game ( Game *g )]...

    For a C program hangman game: Create the function int play_game [play_game ( Game *g )] for a C program hangman game. (The existing code for other functions and the program is below, along with what the function needs to do) (Also the link to program files (hangman.h and library file) is below the existing code section. You can use that to check if the code works) What int play_game needs to do mostly involves calling other functions you've already...

  • Please help with this Intro to programming in C assignment! Intro to Programming in C-Large Program...

    Please help with this Intro to programming in C assignment! Intro to Programming in C-Large Program 3 - Hangman Game Assignment purpose: User defined functions, character arrays, c style string member functions Write an interactive program that will allow a user to play the game of Hangman. You will need to: e You will use four character arrays: o one for the word to be guessed (solution) o one for the word in progress (starword) o one for all of...

  • Overview In this exercise you are going to recreate the classic game of hangman. Your program...

    Overview In this exercise you are going to recreate the classic game of hangman. Your program will randomly pick from a pool of words for the user who will guess letters in order to figure out the word. The user will have a limited number of wrong guesses to complete the puzzle or lose the round. Though if the user answers before running out of wrong answers, they win. Requirements Rules The program will use 10 to 15 words as...

  • C++ Project - Create a memory game in c++ using structs and pointers. For this exercise,...

    C++ Project - Create a memory game in c++ using structs and pointers. For this exercise, you will create a simple version of the Memory Game. You will again be working with multiple functions and arrays. You will be using pointers for your arrays and you must use a struct to store the move and pass it to functions as needed. Program Design You may want to create two different 4x4 arrays. One to store the symbols the player is...

  • JAVA Hangman Your game should have a list of at least ten phrases of your choosing.The...

    JAVA Hangman Your game should have a list of at least ten phrases of your choosing.The game chooses a random phrase from the list. This is the phrase the player tries to guess. The phrase is hidden-- all letters are replaced with asterisks. Spaces and punctuation are left unhidden. So if the phrase is "Joe Programmer", the initial partially hidden phrase is: *** ********** The user guesses a letter. All occurrences of the letter in the phrase are replaced in...

  • This is for C programming: You will be given files in the following format: n word1...

    This is for C programming: You will be given files in the following format: n word1 word2 word3 word4 The first line of the file will be a single integer value n. The integer n will denote the number of words contained within the file. Use this number to initialize an array. Each word will then appear on the next n lines. You can assume that no word is longer than 30 characters. The game will use these words as...

  • Using C Programming: (use printf, scanf) 18. Tic-Tac-Toc Game Write a program that allows two players...

    Using C Programming: (use printf, scanf) 18. Tic-Tac-Toc Game Write a program that allows two players to play a game of tic-tac-toc. Use a two- dimensional char array with three rows and three columns as the game board. Each element of the array should be initialized with an asterisk (*). The program should run a loop that Displays the contents of the board array Allows player 1 to select a location on the board for an X. The program should...

  • Note wordBank, an array of 10 strings (char *s). Your program should do the following: 1....

    Note wordBank, an array of 10 strings (char *s). Your program should do the following: 1. Select a word at random from the wordBank. This is done for you. 2. On each turn display the word, with letters not yet guessed showing as *'s, and letters that have been guessed showing in their correct location 3. The user should have 10 attempts (?lives?). Each unsuccessful guess costs one attempt. Successful guesses do NOT count as a turn. 4. You must...

  • I need help with this. I need to create the hangman game using char arrays. I've...

    I need help with this. I need to create the hangman game using char arrays. I've been provided with the three following classes to complete it. I have no idea where to start. HELP!! 1. /** * This class contains all of the logic of the hangman game. * Carefully review the comments to see where you must insert * code. * */ public class HangmanGame { private final Integer MAX_GUESSES = 8; private static HangmanLexicon lexicon = new HangmanLexicon();...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT