Confused with adding scoring system

Hi, I'm a beginner with C++ and I was making a guess the number program, I wanted to add a score system but the way I went about doing it wouldn't work. I feel like I know how to do it yet my brain has gone completely empty! I want the user to start with 100 points, and lose 10 points each time they get the guess wrong (so basically the game would end after all points are gone - though realistically they should get the number correct since the game is only between 1 - 10)
Can anyone help on how to implement the score system? :(


GAME CODE BELOW


#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

class GuessGame
{
public:
GuessGame();
void Introduce();
bool CheckGuess(int& g);
void Run();

private:
int TheNumber;
int Tries;
int Guess;
int Score;
};


GuessGame::GuessGame() : TheNumber(rand() % 10 + 1), Tries(0), Guess(0), Score(100)
{ }

void GuessGame::Introduce()
{
cout << "Welcome to my number guessing game\n\n";
}

bool GuessGame::CheckGuess(int& g)
{
if (g > TheNumber)
{
(Score - 10);
cout << "Too high!\n\n";
cout << "You have " << Score << " points remaining";
return false;
}

else if (g < TheNumber)
{
(Score - 10);
cout << "Too low!\n\n";
cout << "You have " << Score << " points remaining";

return false;
}

else
{
cout << "Well done, you guessed the right number!\n";
cout << "You got this in " << Tries << " tries.\n";
return true;
}
Score = Score-10;
Topic archived. No new replies allowed.