Project 1
Code
///Name: Luke Shin
///Period: 7
///Project Name: Project 1
///File Name: project1.java
///Date: 11/16/2015
import java.util.Scanner;
public class MoreAdventure{
public static void main(String[] args){
Scanner keyboard = new Scanner(System.in);
String Q1, R1="north",R2="south",R3="roam", Q2,Ra="search",Rb="leave", Q3,Rc="drink",Rd="leave", Q4,Re="in",Rf="leave", Q5,Ri="use",Rii="head", Q6,Riii = "back" ,RiV = "continue" , Q7,RV="continue",RVi="wait", Q8,RVii="yes",RViii="no", Q9,RViiii="hide",RX="fight", Q10,RXi="check",RXii="leave" ;
System.out.print("You are in a forest. Would you like to go \"north\", \"south\", or \"roam\"?: ");
Q1 = keyboard.next();
System.out.println();
if (Q1.equals(R1)){
System.out.print("You found a bag. (\"search\" or \"leave\" it): ");
Q2 = keyboard.next();
System.out.println();
if (Q2.equals(Ra)){
System.out.print("You found a flare! Would you \"use\" it or \"head\" north?: ");
Q5 = keyboard.next();
System.out.println();
if (Q5.equals(Ri)){
System.out.println("The flare brought a bear and it killed you.");
}
else if (Q5.equals(Rii)){
System.out.println("You were able to escape from the forest.");
}
}
else if (Q2.equals(Rb)){
System.out.println("You left the bag, but you have a strong feeling that something important was in the bag.");
System.out.println();
System.out.print("Would yo go \"back\" to search the bag or \"continue\" on your route?");
Q6 = keyboard.next();
System.out.println();
if (Q6.equals(Riii)){
System.out.println("You found a wild animal and got killed.");
}
else if (Q6.equals(RiV)){
System.out.println("It seems like you can't escape from the forest. You died from hypothermia.");
}
}
}
//****************************************************************************************************************
if (Q1.equals(R2)){
System.out.print("You found a bottle of water. Would you \"drink\" it or \"leave\" it?: ");
Q3 = keyboard.next();
System.out.println();
if (Q3.equals(Rc)){
System.out.print("The bottle of water was refreshing. Would you \"contiune\" on your journey or \"wait\"?: ");
Q7 = keyboard.next();
System.out.println();
if (Q7.equals(RV)){
System.out.println("You were able to escape from the forest.");
}
else if (Q7.equals(RVi)){
System.out.println("You were killed by a mob of wild animals.");
}
}
else if (Q3.equals(Rd)){
System.out.print("You are thirsty. Would you like to go back where you found the bottle of water? (\"yes\" or \"no\") ");
Q8 = keyboard.next();
System.out.println();
if (Q8.equals(RVii)){
System.out.println("You died from dehydration");
}
else if (Q8.equals(RViii)){
System.out.println("You were shot by a hunter.");
}
}
}
//*******************************************************************************************************************
if (Q1.equals(R3)){
System.out.print("You found a small house, would you like to go \"in\" or \"leave\"?: ");
Q4 = keyboard.next();
System.out.println();
if (Q4.equals(Re)){
System.out.print("You saw a blood everywhere when you stepped in and someone's opening the door. (\"hide\" or \"fight\"): ");
Q9 = keyboard.next();
System.out.println();
if (Q9.equals(RViiii)){
System.out.println("The man didn't notice and left the house.");
System.out.println();
System.out.println("You used a phone to contact th e police and you were able to escape from the forest.");
}
else if (Q9.equals(RX)){
System.out.println("You got killed.");
}
}
else if (Q4.equals(Rf)){
System.out.print("You found a small village, but it seems an empty village. (\"check\" or \"leave\") : ");
Q10 = keyboard.next();
System.out.println();
if (Q10.equals(RXi)){
System.out.println("You found a car and you successfully escaped from the forest");
}
else if (Q10.equals(RXii)){
System.out.println("You died from hunger.");
}
}
}
}
}
Picture of the output