Assignment #45
Code
///Name: Cody Swain
///Period: 6
///Project Name: AdventureGame
///File Name: AdventureGame.java
///Date: 10/22/15
import java.util.Scanner;
public class AdventureGame
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
String firstAnswer, secondAnswer, thirdAnswer;
System.out.println("Welcome to the Kitchen!!! ");
System.out.println( "You are in your refrigerator!! Would you like to grab the watermelon, or tamale? " );
firstAnswer = keyboard.next();
if ( firstAnswer.equals( "watermelon" ))
{
System.out.println( "Whew, close one.. The tamale was steaming hot. You carefully take out the watermelon and set it on a cutting board. \n Now you have two options: Do you want to cut the watermelon [type \"cut\"],\n or would you like to smash it with your fist [type \"smash\"] ? " );
secondAnswer = keyboard.next();
if (secondAnswer.equals( "cut" ))
{
System.out.println( " You grab a large knife and begin to chop the watermelon. Your knife slips on the watermelon and you cut you hand off.\n Blood begins to shoot out of your stump arm and you have two choices: Do you try to call 911 with you good hand \n [type \"call\"], or do you try to run upstairs to get your wife's attention? ( she is listening to music and can't \n hear you) [type \"wife\"] " );
thirdAnswer = keyboard.next();
if ( thirdAnswer.equals( "call" ))
{
System.out.println( " You run to your phone, while loosing a lot of blood. \nYour reach for the phone line but the electrician wired up your house badly and you get electrocuted from your phone. \n Luckily you die instantly. " );
}
else if ( thirdAnswer.equals( "wife" ))
{
System.out.println( "You run upstairs but become light headed from lack of blood. \n You trip over and fall over the stair railing, falling onto your glass coffee table below. You break 3 ribs and your limp body is bent at a 90 degree angle. \n You die a slow and painful death over the next 10 minutes. " );
}
}
else if (secondAnswer.equals( "smash" ))
{
System.out.println( "You smash the watermelon on your head but it doesnt break. Your head isnt strong enough. You become frustrated and smash the watermelon on your counter. You crack your new mahagony wooden counter and your crazy wife enters the room. She runs at you with a wild glint in her eyes while reaching behind her back. At this point you have the decision to stand there and hope she wants to hug [type \"hug\"] it out, or sprint out of there as fast as you can [type \"sprint\"]. ");
thirdAnswer = keyboard.next();
if ( thirdAnswer.equals( "hug" ))
{
System.out.println("Your wife continues to run at you and pulls out a small butter knife. She stabs you repeatedly until you are dead.");
}
else if ( thirdAnswer.equals( "sprint" ))
{
System.out.println( "You trip over the vase of flowers your wife just bought to suprise you with, and your head cracks open on the edge of your coffee table. You die. " );
}
}
}
else if ( firstAnswer.equals( "tamale" ))
{
System.out.println( "Good choice. A tamale is actual food. Do you microwave it[type \"microwave\"], or cook it in the oven [type \"oven\"] ? " );
secondAnswer = keyboard.next();
if (secondAnswer.equals( "microwave" ))
{
System.out.println( " The microwave makes wierd noise, and doesn't work. Do you try to fix it[type \"fix\"], or do you do nothing[type \"nothing\"] " );
thirdAnswer = keyboard.next();
if ( thirdAnswer.equals( "fix" ))
{
System.out.println( " You take the microwave out of its cubby and unplug the wiring. Sadly the insulation has all deteriorated and you die from electrocution. " );
}
else if ( thirdAnswer.equals( "nothing" ))
{
System.out.println( "You don't die from elecution which would have happened if you tried to fix it. You live happily ever after and have 3 of the cutest babies. You die surrounded by all your friends and family, absolutely 100% content with your life. " );
}
}
else if (secondAnswer.equals( "oven" ))
{
System.out.println( "You turn the oven on, wait for it to heat up, and shove the tamale in it. You then set a timer for 25 minutes and try to think of how you will kill time. You can go on a short run[type \"run\"] or go on a short bike ride [type \"bike\"]. ");
thirdAnswer = keyboard.next();
if ( thirdAnswer.equals( "run" ))
{
System.out.println("You run out your door and into the street. A mom driving three children rams into you at 55 miles per hour and your body crumples. You die instantly.");
}
else if ( thirdAnswer.equals( "bike" ))
{
System.out.println( "You go get your bike and helmet from the garage. You bike out into the street and are immediately flattened by a school bus fall of children. You are dead. " );
}
}
}
}
}
Picture of the output