Finished 02, but need help with TODO!

Hey all!

TL;DR Link to code is at the bottom, and would appreciate some help with my TODOs in the main.cpp :smiley:

Finished section 02 with some difficulty with the challenges as it was my very first time with C++.

My girlfriend asked for some more detailed instructions with the game while play testing so thought I could try to add those inā€¦

I attempted to add instructions into the main.cpp file, but only got as far as asking the player if they want to play, or read the instructions. Regardless of the response, the game just started up!

Could anybody help me understand how to implement this code?

https://drive.google.com/drive/folders/0B9Vj1kvMy8cQc1ZFcFIyZXN5dFk?usp=sharing

in the

bool askForInstructions()

you want to return a bool, but

PrintInstructions()

is not a bool, itā€™s function itself, so you cannot return it.

What you could do is Call the Function PrintInstructions() instead.
The AskForInstruction doesnā€™t have to return anything then.

void AskForInstructions()
{
   .... //do the checks like you did 
   //yes:
        PrintInstructions(); //Call the function to print the instructions
   //no:
        return;
}

Thereā€™s no need for a boolean here. Though you COULD use one and set it to true/false depending on the palyerā€™s choice
and then create an if-else inside the mainfunction to either call PrintInstructions() or not.

Thank you for the quick reply Daniel!

I went back in and was able to make the changes that you suggested. I kept the AskForInstructions as a bool at first and found that I could still use it as long as I returned it as false. It looked messy so I switched it out and now it works perfectly.

I even did a little searching and added a " system(ā€œpauseā€); after my instructions to clean it up a little.

Thanks again for your help!

Privacy & Terms