I am trying to learn C++ and this is the first program I wrote besides "Hello World". I really need help :( with almost all of it but I am completely confused on how to assign the values to the chests then have the numbers randomized so they are not the same if the player chooses to play multiple times.
I have to write a program to implement a game that is played as follows:
• Start by hiding prizes in 4 treasure chests. One contains 500 chips, one contains 300 chips, one contains 100 chips, and one contains ‘you lose’.
• The person playing chooses a chest to open.
• The player may open chests until they choose to quit or until they open the chest with ‘you lose’.
• The goal is to win as much as the player can without opening ‘you lose’.
• Have different ending messages depending on how much the player wins or if they lose.
You could just "cheat", in a way, and regardless of which chest the player selects, randomly choose one of the four options.
It could work like this: Main loop
Ask user for pick, or if they want to end the game (break)
Generate random number to determine result
If 1:
Give 500 chips
If 2:
Give 300 chips
If 3:
Give 100 chips
If 4:
End game with game over message
end loop
Display message based on chips the player acquired
Edit: Also, why did you post this same topic on multiple forums...?
I can't just say if the player chooses case one they get 500 coins becuase then the next player chooses that case and gets the same total. I need it to be different everytime.
I posted it twice because I realized it would probably fit in this forum better and just didn't delete the other. I am very confused and the more help I get the better.
Did you miss the part right before that? Generate a random number to determine the result. I was suggesting it didn't matter whether you randomly gave each chest an option and had them pick, or simply ran a random generator for each option, with the choice being irrelevant.