SHARE
TWEET

Untitled

Jenny_ Jul 18th, 2019 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import hangman.Hangman;
  2. import java.util.Scanner;
  3.  
  4. public class HangmanUserInterface {
  5.  
  6.     public static void main(String[] args) {
  7.         Scanner reader = new Scanner (System.in);
  8.         Hangman hangman = new Hangman ();
  9.  
  10.         System.out.println("***********");
  11.         System.out.println("* HANGMAN  *");
  12.         System.out.println("***********");
  13.         System.out.println("");
  14.         printMenu ();
  15.         System.out.println("");
  16.  
  17.         while (hangman.gameOn ()) {
  18.             System.out.println("Type a command: ");        // Instructions to user
  19.             String quit = "quit";       // variable
  20.             String status = "status";   // variable
  21.  
  22.             String command = reader.nextLine ();            // reading the variable command
  23.             if (command.equals(quit)) {                    // 1st if
  24.                 break;                                      // what to do
  25.             }
  26.             if (command.equals (status)) {
  27.                 hangman.printStatus();
  28.             }
  29.         }
  30.                 System.out.println("Thank you for playing!");
  31.     }
  32.  
  33.     public static void printMenu() {
  34.         System.out.println(" * menu *");
  35.         System.out.println("quit   - quits the game");
  36.         System.out.println("status  - prints the game status");
  37.         System.out.println("a single letter uses the letter as a guess");
  38.         System.out.println("an empty line prints this menu");
  39.     }
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top