I haven’t yet seen Ben’s solution to this yet however I had a go at it in the simplest way I could think of it. I would greatly appreciate if someone could tell me in detail if anything I do is bad practice and why it is so.
I firstly changed the prototyping of the GetGuess() function in the main.cpp file so that it accepts an int as an argument.
I then declared an int of ‘TriesLeft’ which calls the GetCurrentTry() from the BCGame class to get the amount of tries a player is allowed.
The value of which I set in the class:
I then wrote the following code so that every time the player makes a guess, 1 try is taken away from the maximum tries allowed.
I then passed ‘TriesLeft’ to GetGuess()
Which displays the updated value with each iteration of the loop:
it works perfectly. Would just appreciate some feed back.
UPDATE: I am aware that I used ‘GetCurrentTry’ from the class instead ‘GetMaxTries’. Let’s assume for the sake of the discussion that I have used GetMaxTries.