C++ I\'m having a problem with this C++ program I\'m working on. Here, I\'m work
ID: 641158 • Letter: C
Question
C++
I'm having a problem with this C++ program I'm working on. Here, I'm working on a variation of the Mastermind game that only uses numbers instead of colors.
The game also allows an infinite number of tries, but will output your score.
I'm having a hard time with the game itself. Here's my code. Please help!
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
struct Player
{
string name;
int highScores[6];
bool cheatOn;
};
struct Board
{
int numHoles;
int holes;
};
struct Guess
{
int count;
int numHoles;
int holes;
};
void printHighScores(Player);
void readHighScores(Player);
void updateHighScore(Player,Guess);
void getPlayer();
void getBoard();
void playGame(Player);
void menu(Player);
int main()
{
cout<<"Welcome to Mastermind."<<endl;
getPlayer();
system("PAUSE");
return 0;
}
void getPlayer(Player playerOne)
{
cout<<"Please enter your name. "<<endl;
cin>>playerOne.name;
menu(playerOne);
}
void menu(Player playerOne)
{
char choice;
cout<< playerOne.name << " ,Choose and option "<<endl;
cout<<"(P)lay"<<endl;
cout<<"(Q)uit"<<endl;
cout<<"Choice: "<<endl;
cin>>choice;
switch (choice)
{
case 'q':
case 'Q': cout<<"end"<<endl;
break;
case 'p':
case 'P': playGame(playerOne);
default: cout<<"not a valid option - try again."<<endl;
break;
}
}
void playGame(Player playerOne)
{
getBoard();
}
void getBoard()
{
//will create the game "board" but how do I do it?
}
void printHighScores(Player playerOne)
{
//This will print high score
}
void getHighScores(Player playerOne)
{
//This will retrieve high score
}
Explanation / Answer
#include #include #include #include #include #include using namespace std; int main(){ int choose; int choose2; int c1, c2, c3, c4; int g1, g2, g3, g4; //int D; //bool menu = true; MenuOne: coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.