Я хотел бы знать, как сделать игровой цикл в методе game() после нажатия no в качестве выбора, когда спросил, закончить ли игру.
Вот мой код:
Код: Выделить всё
private static void game() //game method
{
//...
int play = JOptionPane.showOptionDialog(null
,"End"
, "Do you want to play again?"
, JOptionPane.PLAIN_MESSAGE
,JOptionPane.DEFAULT_OPTION
, null
, again
, again[1]);
//end of game
if (play == 0)
System.exit(0);//exit
else
/* what do I put here to restart the program in the same method(game())
after pressing the No button on the JOptionPane??? */
System.out.println("Service not available");
Подробнее здесь: https://stackoverflow.com/questions/348 ... m-a-method