How to add the “play again?” feature for java

后端 未结 3 1335
生来不讨喜
生来不讨喜 2021-01-24 17:01

Im making a guessing game for my class and I need some help for adding a \"play again\" feature at the end of the game when you\'ve guessed the right number:

pub         


        
3条回答
  •  春和景丽
    2021-01-24 18:02

    One simple approach would be to move the code you've written into a function

       public void play() { 
       ...
       }
    

    and from main do something like:

       do { 
          play();
          playAgain = promptUser;
       } while(playAgain);
    

提交回复
热议问题