Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. public void main() {
  2. String userInput;
  3. boolean done;
  4. Scanner keyboard = new Scanner(System.in);
  5. do {
  6. System.out.println("Welcome to Hangman!");
  7. System.out.println("Do you want to play?");
  8. userInput = keyboard.next();
  9. if (userInput == "Yes" || userInput == "yes" || userInput == "y" || userInput == "Y") {
  10. done = true;
  11. } else {
  12. done = false;
  13. }
  14. while (!done) {
  15. System.out.println(getDisguisedWord());
  16. System.out.println("Guess a letter: ");
  17. String guess = keyboard.next();
  18. makeGuess(guess);
  19. if (gameOver()) {
  20. String ui;
  21. System.out.println("Do you want to play again?");
  22. ui = keyboard.next();
  23. if (ui == "Yes" || ui == "yes" || ui == "Y" || ui == "y") {
  24. done = true;
  25. } else {
  26. done = false;
  27. }
  28. }
  29. }
  30. } while(done == false);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement