Advertisement
Guest User

a

a guest
Mar 12th, 2025
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class UnadvancedDnD {
  4. public static void main(String[] args) {
  5. Scanner sc = new Scanner(System.in);
  6.  
  7. System.out.print("Please enter an action: ");
  8. String action = sc.nextLine();
  9.  
  10. int work = 0;
  11. while (work == 0) {
  12. if (action.equals("x")) {
  13. System.out.println("Bye!");
  14. work++;
  15. }
  16. else if (action.equals("u")) {
  17. System.out.println("You go one square up.");
  18. work++;
  19. }
  20. else if (action.equals("d")) {
  21. System.out.println("You go one square down.");
  22. work++;
  23. }
  24. else if (action.equals("l")) {
  25. System.out.println("You go one square left.");
  26. work++;
  27. }
  28. else if (action.equals("r")) {
  29. System.out.println("You go one square right.");
  30. work++;
  31. }
  32. else if (action.equals("s")) {
  33. System.out.println("You search the square for treasure. You find nothing.");
  34. work++;
  35. }
  36. else if (action.equals("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. work++;
  39. }
  40. else if (action.equals("e")) {
  41. System.out.println("You eat some food. You regain 0 hit points.");
  42. work++;
  43. }
  44. else {
  45. System.out.println("I don't understand.");
  46. work++;
  47. }
  48.  
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement