Assignemnt #45 Choose Your Own Adventure
Code
/// Name: Jake Johnson
/// Period: 7
/// Program Name: Choose Your Own Adventure
/// File Name: ChooseYourOwnAdventure.java
/// Date Finished: 11/10/2015
import java.util.Scanner;
public class ChooseYourOwnAdventure
{
public static void main (String[] args)
{
String A1, A2, A3;
Scanner keyboard = new Scanner(System.in);
System.out.println("WELCOME TO JAKE'S ADVENTURE");
System.out.println("You wake up in a creepy mansion! Would you like to go \"downstairs\" or to the \"kitchen\"? ");
A1 = keyboard.next();
if (A1.equals("downstairs"))
{
System.out.println("In the basement you see a \"closet\" and a \"wardrobe\". which do you open?");
A2 = keyboard.next();
if (A2.equals("closet"))
{
System.out.println("In the closet you see a spooky ghost! would you like to \"fight\" the spooky ghost or \"run\" from the spooky ghost?");
A3 = keyboard.next();
if (A3.equals("fight"))
{
System.out.println("you fight the spooky ghost and lose. You die.");
}
else if (A3.equals("run"))
{
System.out.println("You try to run from the spooky ghost, but he catches you. You die.");
}
}
else if (A2.equals("wardrobe"))
{
System.out.println("You open the wardrobe and a spooky ghost appears! THE GHOST DEMANDS YOU GIVE HIM YOUR SOUL? Do you give him your soul? (\"yes\" or \"no\"");
A3 = keyboard.next();
if (A3.equals("yes"))
{
System.out.println("The ghost consumes your soul, you die.");
}
else if (A3.equals("no"))
{
System.out.println("You refuse to give him your soul, and he eats you. You die.");
}
}
}
else if (A1.equals("kitchen"))
{
System.out.println("You go in the kitchen and you see a \"rerfrigerator\" and a \"cabinet\". Which do you open?");
A2 = keyboard.next();
if (A2.equals("refrigerator"))
{
System.out.println("You open the refrigerator, but there is a bunch of nasty food in it, do you eat the food? (\"yes\" or \"no\")");
A3 = keyboard.next();
if (A3.equals("yes"))
{
System.out.println("you eat the food and die of food poisoning");
}
else if (A3.equals("no"))
{
System.out.println("you refuse to eat the food and die of starvation");
}
}
else if (A2.equals("cabinet"))
{
System.out.println("In the cabinate you find some expired corn flakes. Do you eat them? (\"yes\" or \"no\")");
A3 = keyboard.next();
if (A3.equals("yes"))
{
System.out.println("you eat the cornflakes and find maggots in it! You die of a heart attack.");
}
else if (A3.equals("no"))
{
System.out.println("you refuse to eat the corn flakes and die of starvation");
}
}
}
}
}
Picture of the output