Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void main() {
- String userInput;
- boolean done;
- Scanner keyboard = new Scanner(System.in);
- do {
- System.out.println("Welcome to Hangman!");
- System.out.println("Do you want to play?");
- userInput = keyboard.next();
- if (userInput == "Yes" || userInput == "yes" || userInput == "y" || userInput == "Y") {
- done = true;
- } else {
- done = false;
- }
- while (!done) {
- System.out.println(getDisguisedWord());
- System.out.println("Guess a letter: ");
- String guess = keyboard.next();
- makeGuess(guess);
- if (gameOver()) {
- String ui;
- System.out.println("Do you want to play again?");
- ui = keyboard.next();
- if (ui == "Yes" || ui == "yes" || ui == "Y" || ui == "y") {
- done = true;
- } else {
- done = false;
- }
- }
- }
- } while(done == false);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement