Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class UnadvancedDnD {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- boolean program_running = true;
- boolean valid_input = true;
- String command = "";
- while(program_running){
- valid_input = true;
- System.out.print("Please enter an action: ");
- command = sc.nextLine();
- switch(command){
- case "x":
- System.out.println("Bye!");
- program_running = false;
- break;
- case "u":
- System.out.println("You go one square up.");
- break;
- case "d":
- System.out.println("You go one square down.");
- break;
- case "l":
- System.out.println("You go one square left.");
- break;
- case "r":
- System.out.println("You go one square right.");
- break;
- case "s":
- System.out.println("You search the square for treasure. You find nothing.");
- break;
- case "h":
- 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.");
- break;
- case "e":
- System.out.println("You eat some food. You regain 0 hit points.");
- break;
- default:
- valid_input = false;
- break;
- }
- if(!valid_input){
- System.out.println("I don't understand.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement