Help xD | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Help xD

I have made a short game program with the help of the community codes but I am having trouble creating a restart option if the character dies I got a while loop going when the character has health and when it becomes false it returns the score and a short message about Dying followed by the option do you wish to continue how do I implement or get it to read the next line eg. string restart == console.readline(); If (Restart == yes || restart == y) { // also what do I put here to restart // } Else Break;

4th Jul 2018, 9:33 PM
Harry
Harry - avatar
10 Answers
+ 4
Put a second while loop around your existing code.
4th Jul 2018, 11:50 PM
John Wells
John Wells - avatar
+ 4
I made a few different changes. You had the restart in the wrong place. You forgot to reset the players stats on restart. https://code.sololearn.com/c18Oo511500b
6th Jul 2018, 2:50 PM
John Wells
John Wells - avatar
+ 2
string restart = "y"; while (string.compare(restart, "y")) { // existing code restart = console.readline(); }
5th Jul 2018, 4:29 PM
John Wells
John Wells - avatar
+ 1
thank you
6th Jul 2018, 9:32 AM
Harry
Harry - avatar
+ 1
line 123 needs to return the string returned by the recursive call to pass it up.
6th Jul 2018, 12:27 PM
John Wells
John Wells - avatar
+ 1
thank you
6th Jul 2018, 12:48 PM
Harry
Harry - avatar
+ 1
thank you so much
6th Jul 2018, 2:51 PM
Harry
Harry - avatar
0
how do i get it to activate the second while loop only if they answer yes
5th Jul 2018, 7:11 AM
Harry
Harry - avatar
0
i have messed up somewhere my startTurn() is no longer returning a value this may be easier here is my code can you have a look please would greatly appreciate it https://code.sololearn.com/cWppqxcEH02C
6th Jul 2018, 10:23 AM
Harry
Harry - avatar
0
error CS0117: 'string' does not contain a definition for 'StartTurn' error CS0161: 'Game.StartTurn()': not all code paths return a value
6th Jul 2018, 2:20 PM
Harry
Harry - avatar