However, I am wondering how exactly a double linked list would be able to be implemented to make moving from room to room a bit easier? It seems like it would make my code look much cleaner and stop my headache. Could someone explain to me how I would use it in concurrence with this code? Or maybe point me in the direction of a good example for double linked lists? Thank you.
import java.util.Scanner;
public class HauntedMansion {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String choice;
@SuppressWarnings("resource")
Scanner user_in = new Scanner(System.in);//This creates an 'opening' for user input
System.out.println("Welcome to the Haunted Mansion. You see an expansive staircase ahead of you and rooms to your left and right."+"\n"+"Type 'upstairs' and hit enter to go up the staircase, 'right' to go to the room on your right,"+"\n"+"or 'left to go to the room on your left.");
choice = user_in.nextLine();//this allows the user to input and continue on
if(choice.equals("upstairs")){
System.out.println("You are now upstairs."+"\n"+"There is a musky and dark hallway to your left and a door in front of you."+"\n"+"Type 'left' and hit enter to go down the hallway or 'door' to open the door in front of you.");
choice = user_in.nextLine();
if(choice.equals("left")){
System.out.println("As you turn to go down the hallway, you notice a dim light floating at the end of the hallway. The rest of the hall is nearly black."+"\n"+" With each step, the floorboard creaks and dust falls from the beams overhead."+"\n"+"The dim light grows brighter the closer you get to it."+"\n"+"'continue' to go on or 'back' to return to the staircase.");
choice = user_in.nextLine();
if(choice.equals("continue")){
System.out.println("The glowing light appears to be coming from a cellphone on the floor."+"\n"+"Pick it up? 'Y' or 'N'");
choice = user_in.nextLine();
if(choice.equals("Y")){
System.out.println("There is a new text message on the cellphone.");
choice = user_in.nextLine();
}else if(choice.equals("N")){
System.out.println("The cellphone keeps flashing that there is a new message. You notice that the battery is nearly empty. This could serve as a good light if you could find a charge for it. You pick it up anyways. Do you read the message?"+"\n"+"'Y' or 'N'");
choice = user_in.nextLine();
}
}else if(choice.equals("back")){
System.out.println("As you turn your back to the light you feel a cold breeze flow through the room. A clammy hand wraps itself around your neck..."+"\n"+"GAME OVER");
}
}
else if(choice.equals("door")){
System.out.println("You reach your hand out and turn the door handle. There is a slight rattle as you push open the door.");
}
}
else if(choice.equals("right")){
System.out.println("You are now in the kitchen.");
}
else if(choice.equals("left")){
System.out.println("You are now in the dining room");
}
else{
System.out.println("That is not a valid answer.");
}
}
}

New Topic/Question
Reply



MultiQuote







|