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";
}
PROGRAM DESCRIPTION: In this assignment, you will be creating a memory matching game in C++. In t...
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. (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 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 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, 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 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 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 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. 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 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();...