SHARE
TWEET

Untitled

a guest Sep 21st, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.IOException;
  2. import java.util.Scanner;
  3.  
  4. public class Adventure {
  5.  
  6.     public static void main(String[] args) throws IOException {
  7.         Scanner keyboard = new Scanner(System.in);
  8.         //Choose your name
  9.         System.out.print("Choose your name:");
  10.         String name = keyboard.next();
  11.         System.out.println("Welcome, " + name + "! Please select a destination.");
  12.         int choice = 0;
  13.         //Will keep looping until number 9 is entered
  14.         while (choice != 9) {
  15.             System.out.println();
  16.             System.out.println("(1): Left at the fork");
  17.             System.out.println("(2): Down the middle road");
  18.             System.out.println("(3): Right at the fork");
  19.             System.out.println("(9): Go home");
  20.             System.out.println();
  21.             System.out.print("Choose a destination: ");
  22.             choice = keyboard.nextInt();
  23.             if (choice == 1) {
  24.                 System.out.println("You enter a dark forest, covered in spiderwebs and overgrown with disgusting looking plants.");
  25.                 System.out.println("You have been poisoned by the plant pollen.");
  26.                 System.out.println("You have died!");
  27.             } else if (choice == 2) {
  28.                 System.out.println("You walk the path for about a quarter of a mile before being ambushed by bandits.");
  29.                 System.out.println("What do you do?");
  30.                 System.out.println("(1): Fight!");
  31.                 System.out.println("(2): Run!");
  32.                 choice = keyboard.nextInt();
  33.                 if (choice == 1) {
  34.                     System.out.println("You have taken a massive wound!");
  35.                     System.out.println("You have died!");
  36.                 }
  37.                 else if (choice == 2) {
  38.                         System.out.println("You quickly run to safety!");
  39.                 }
  40.             } else if (choice == 3) {
  41.                 System.out.println("You take the road to the right. It leads you to small pot of gold!");
  42.                 System.out.println("A small man jumps out to attack you!");
  43.                 System.out.println("You kick his ass.");
  44.                 System.out.println("You are rich! You win!");
  45.                 System.out.println("Choose where to spend your winnings!");
  46.                 System.out.println("(1): Casino");
  47.                 System.out.println("(2): Charity");
  48.                 System.out.println("(3): Put it in the bank");
  49.                 System.out.println("(9): Stop playing");
  50.                 break;
  51.             } else if (choice == 9) {
  52.                 System.out.println("May we travel again.");
  53.                 System.out.println("Press <Enter> to close");
  54.                 System.in.read();
  55.                 System.exit(0);
  56.             } else {
  57.                 System.out.println("Option Not Available");
  58.             }
  59.         }
  60.             choice = keyboard.nextInt();
  61.             if (choice == 1) {
  62.                 System.out.println("You blow your money at the casino and end up worse than you started!");
  63.                 System.out.println("Press <Enter> to close");
  64.                 System.in.read();
  65.                 System.exit(0);
  66.             } else if (choice == 2) {
  67.                 System.out.println("You donate your winnings to charity! Everyone loves you! Seriously. You are awesome.");
  68.                 System.out.println("Press <Enter> to close");
  69.                 System.in.read();
  70.                 System.exit(0);
  71.             } else if (choice == 3) {
  72.                 System.out.println("You get mugged on the way there and died.");
  73.                 System.out.println("Game over");
  74.                 System.out.println("Press <Enter> to close");
  75.                 System.in.read();
  76.                 System.exit(0);
  77.             } else if (choice == 9) {
  78.                 System.out.println("May we travel again.");
  79.                 System.out.println("Press <Enter> to close");
  80.                 System.in.read();
  81.                 System.exit(0);
  82.             } else {
  83.                 System.out.println("Option Not Available");
  84.             }
  85.         }
  86.     }
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
 
Top