I have a class named TestMaze
. I have another class named DisplayHome
which has a method called gameOver()
:
public void gameOver()
{
Console.Write("GAME OVER!");
Console.Write("Play Again? Y/N");
if(char.ToLower(Convert.ToChar(Console.Read())=='y')
//Main()
else
Environment.Exit(1);
}
How can I call the Main method?
PS. they have the same namespace. I just need to know how can I call the Main method again.
You should have a Play() method inside your Main... and GameOver() should call Play() if user enters 'y'.
Refactor your code. Move whatever needs to be called into another function, and call it from both, main, and gameOver.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With