Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.31 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class UnadvancedDnD {
  4.     public static void main(String[] args) {
  5.        
  6.         Scanner sc = new Scanner(System.in);
  7.         boolean program_running = true;
  8.         boolean valid_input = true;
  9.         String command = "";
  10.        
  11.         while(program_running){
  12.             valid_input = true;
  13.             System.out.print("Please enter an action: ");
  14.             command = sc.nextLine();
  15.  
  16.             switch(command){
  17.                 case "x":
  18.                     System.out.println("Bye!");
  19.                     program_running = false;
  20.                     break;
  21.                 case "u":
  22.                     System.out.println("You go one square up.");
  23.                     break;
  24.                 case "d":
  25.                     System.out.println("You go one square down.");
  26.                     break;
  27.                 case "l":
  28.                     System.out.println("You go one square left.");
  29.                     break;
  30.                 case "r":
  31.                     System.out.println("You go one square right.");
  32.                     break;
  33.                 case "s":
  34.                     System.out.println("You search the square for treasure. You find nothing.");
  35.                     break;
  36.                 case "h":
  37.                     System.out.println("You hide, waiting for enemies to come by. It gets boring after about an hour and a half, so you give up.");
  38.                     break;
  39.                 case "e":
  40.                     System.out.println("You eat some food. You regain 0 hit points.");
  41.                     break;
  42.                 default:
  43.                     valid_input = false;
  44.                     break;
  45.             }
  46.            
  47.             if(!valid_input){
  48.                 System.out.println("I don't understand.");
  49.             }
  50.         }
  51.            
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement