include
include
using namespace std;
namespace game
{
struct game
{
unsigned short int score = 0;
unsigned short int correctAnswers = 0;
unsigned short int playedQuestions = 0;
string playerName = "unknown";
void yourInformation();
void gameStart();
void gameInfo();
};
}; // end of namespace
void game::game::yourInformation()
{
cout << "Welcome to Play a quiz Game which played by console " << endl;
string userData = "unknown";
cout << "Enter your Name : ";
getline(cin, userData);
this->playerName = userData;
cout << "Ok Mr./MS. " << this->playerName << " do you want to play a Game ? ";
getline(cin, userData);
if (userData == "yes" || "Yes" || "YES")
{
this->gameStart();
}
}
void game::game::gameStart()
{
string userData = "null";
cout << "Enter the Name of Capital city of India ";
getline(cin, userData);
this->score += userData == "new delhi" || "New Delhi" || "delhi" || "Delhi" ? 1 : 0;
this->gameInfo();
cout << "Capital City of China : ";
getline(cin, userData);
this->score += userData == "Beijing" || "beijing" || "BEIJING" ? 1 : 0;
this->gameInfo();
cout << "who is the president of Russia ? :";
getline(cin, userData);
this->score += userData == "Valadmir Putin" || "Putin" || "putin" || "Valadmir putin" || "PUTIN" || "VALADMIR PUTIN" ? 1 : 0;
this->gameInfo();
cout << "Which is world's Fastet Object Oriented Programming ? ";
getline(cin, userData);
this->score += userData == "cpp" || "Cpp" || "c++" || "C++" || "Cplusplus" || "cplusplus" || "cplus plus programming" || "cpp language" ? 1 : 0;
this->gameInfo();
cout << "which Operating system mostly used at Servers and Satelite ? ";
cout << "(a). windows, (b). Linux, (c).Mac, (d). Android" << endl;
getline(cin, userData);
this->score += userData == "b" || "Linux" || "linux" || "B" || "LINUX" ? 1 : 0;
this->gameInfo();
cout << "What is your Name ? ";
getline(cin, userData);
this->score += userData == this->playerName ? 1 : 0;
this->gameInfo();
cout << "thanks for playing Game : " << endl;
}
void game::game::gameInfo()
{
this->correctAnswers = this->score;
this->playedQuestions++;
cout << "=============================" << endl;
cout << "Score : " << this->score << endl;
cout << "Correct Answer : " << this->correctAnswers << endl;
cout << "Played Questions : " << this->playedQuestions << endl;
cout << "===============================" << endl;
}
void information()
{
game::game myGame;
myGame.yourInformation();
}
int main()
{
information();
return 0;
}
Top comments (1)
You really need to better format your code using Markdown. Otherwise what you're posting is to hard to read to bother with.