Skip to content

Instantly share code, notes, and snippets.

@sephto
Created November 4, 2014 18:06
Show Gist options
  • Save sephto/5ec7fffb1a8d16a4bedf to your computer and use it in GitHub Desktop.
Save sephto/5ec7fffb1a8d16a4bedf to your computer and use it in GitHub Desktop.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package haunted.house;
import javax.swing.JOptionPane;
/**
*
* @author LearningFirst
*/
public class HauntedHouse {
public static void main(String[] args) {
boolean inHouse = true;
String victimName = "";
String Message = "What's your name?";
while (victimName.equals("")){
victimName = JOptionPane.showInputDialog(null, Message, "House of the Dead",JOptionPane.PLAIN_MESSAGE);
Message = "You must have a name";
}
String rooms = "";
while(inHouse){
switch (rooms){
case "Living Room":
Room livingRoom = new Room(rooms, "Chest");
String[] LivingRoom = {"Go to the Bathrrom","Explore","Exit Game"};
String livingRoomMessage = "You are now in the " + livingRoom.getRoomName()+"\nYou see a "+ livingRoom.getRoomItem() + " in the middle of the room...";
int livingRoomOprions = makeDialog(livingRoomMessage, LivingRoom);
rooms = LivingRoom[livingRoomOprions];
break;
case "Dining Room":
Room diningRoom = new Room(rooms, "Candelabra");
String[] diningRoomChoices = {"Go to the Kitchen","Explore","Exit Game"};
String diningRoomMessage = "You are now in the " + diningRoom.getRoomName()+"\nYou see a "+ diningRoom.getRoomItem() + " in the center of the dining room table...";
int diningRoomOptions = makeDialog(diningRoomMessage, diningRoomChoices);
rooms = diningRoomChoices[diningRoomOptions];
break;
case "Stairs":
break;
default:
String[] frontDoor = {"Living Room","Dining Room", "Upstairs","Exit Game"};
String frontDoorMessage = "Where do you want to go?";
int frontDoorOptions = makeDialog(frontDoorMessage, frontDoor);
rooms = frontDoor[frontDoorOptions];
break;
}
}
}
public static int makeDialog(String message, String[] options){
int menu1 = JOptionPane.showOptionDialog(null, message, "House of the Dead",JOptionPane.DEFAULT_OPTION,
JOptionPane.PLAIN_MESSAGE, null, options, options[options.length-1]);
return menu1;
}
/*
String victimName = JOptionPane.showInputDialog(null, "What's your name?", "House of the Dead",JOptionPane.PLAIN_MESSAGE);
while ("".equals(victimName)){
JOptionPane.showMessageDialog(null,"You Must Have a Name","House of Terror",JOptionPane.PLAIN_MESSAGE);
victimName = JOptionPane.showInputDialog(null, "What's your name?", "House of the Dead",JOptionPane.PLAIN_MESSAGE);
}
if(victimName!=null) {
String[] frontDoor = {"Living Room","Dining Room", "Upstairs","Exit Game"};
int menu1 = JOptionPane.showOptionDialog(null, "Where do you want to go?", "House of the Dead",JOptionPane.DEFAULT_OPTION,
JOptionPane.PLAIN_MESSAGE, null, frontDoor, frontDoor[3]);
String room;
if (menu1==0){
room = "Living Room";
Room livingRoom = new Room(room, "Chest");
JOptionPane.showMessageDialog(null,"You are now in the " + livingRoom.getRoomName()+"\nYou see a "+ livingRoom.getRoomItem() + " in the middle of the room...","House of Terror",JOptionPane.PLAIN_MESSAGE);
String[] livingRoomChoices = {"Go to the Bathrrom","Explore","Exit Game"};
int menu3 = JOptionPane.showOptionDialog(null, "What do you want to do", "House of the Dead",JOptionPane.DEFAULT_OPTION,
JOptionPane.PLAIN_MESSAGE, null, livingRoomChoices, livingRoomChoices[2]);
if(menu3==0){
room = "Bathroom";
Room2 bathRoom = new Room2(room, "Mirror","Shower");
JOptionPane.showMessageDialog(null,"You are now in " + bathRoom.getRoomName()+ "\nYou see:\nA foggy "+ bathRoom.getRoomItem()+"\nA running " + bathRoom.getRoomItem2() ,"House of Terror",JOptionPane.PLAIN_MESSAGE);
}
else if (menu3==1){
}
else{
JOptionPane.showMessageDialog(null, "Good Bye") ;
}
}
else if (menu1==1){
room ="Dining Room";
Room diningRoom = new Room(room, "Candelabra");
JOptionPane.showMessageDialog(null,"You are now in the " + diningRoom.getRoomName()+"\nYou see a "+ diningRoom.getRoomItem() + " in the center of the dining room table...","House of Terror",JOptionPane.PLAIN_MESSAGE);
String[] diningRoomChoices = {"Go to the Kitchen","Explore","Exit Game"};
int menu4 = JOptionPane.showOptionDialog(null, "What do you want to do", "House of the Dead",JOptionPane.DEFAULT_OPTION,
JOptionPane.PLAIN_MESSAGE, null, diningRoomChoices, diningRoomChoices[2]);
if(menu4==0){
room = "Kitchen";
Room2 kitchen = new Room2(room, "Refrigerator","Cabinet");
JOptionPane.showMessageDialog(null,"You are now in " + kitchen.getRoomName()+ "\nYou see:\nA "+ kitchen.getRoomItem()+"\nA open " + kitchen.getRoomItem2() ,"House of Terror",JOptionPane.PLAIN_MESSAGE);
String[] kitchenChoices = {"Go to the Pantry","Explore","Exit Game"};
int menu6 = JOptionPane.showOptionDialog(null, "What do you want to do", "House of the Dead",JOptionPane.DEFAULT_OPTION,
JOptionPane.PLAIN_MESSAGE, null, kitchenChoices, kitchenChoices[2]);
if(menu6==0){
room = "Pantry";
}
else if (menu6==1){
}
else {
JOptionPane.showMessageDialog(null, "Good Bye") ;
}
}
else if (menu4==1){
}
else{
JOptionPane.showMessageDialog(null, "Good Bye") ;
}
}
else if(menu1==2){
room = "Top of Stairs";
Room upStairs = new Room(room, "nothing that catches your eye...");
JOptionPane.showMessageDialog(null,"You are now in the " + upStairs.getRoomName()+"\nYou see "+ upStairs.getRoomItem() ,"House of Terror",JOptionPane.PLAIN_MESSAGE);
String[] topOfStairs = { "Master Bedroom","Grandma's Bedroom", "Alice's Bedroom","Exit Game"};
int menu2 = JOptionPane.showOptionDialog(null, "Where do you want to go?", "House of the Dead",JOptionPane.DEFAULT_OPTION,
JOptionPane.PLAIN_MESSAGE, null, topOfStairs, topOfStairs[3]);
if (menu2==0){
room = "Master Bedroom";
Room masterBedRoom = new Room(room, "Jewelry Box");
JOptionPane.showMessageDialog(null,"You are now in the " + masterBedRoom.getRoomName()+"\nYou see a beautiful "+ masterBedRoom.getRoomItem() ,"House of Terror",JOptionPane.PLAIN_MESSAGE);
String[] masterBedRoomChoices = {"Go to the Bathroom","Explore","Exit Game"};
int menu5 = JOptionPane.showOptionDialog(null, "What do you want to do", "House of the Dead",JOptionPane.DEFAULT_OPTION,
JOptionPane.PLAIN_MESSAGE, null, masterBedRoomChoices, masterBedRoomChoices[2]);
if(menu5==0){
room = "Master Bathroom";
Room2 masterBathRoom = new Room2(room, "Intricate Oil Lamp","Shower");
JOptionPane.showMessageDialog(null,"You are now in " + masterBathRoom.getRoomName()+ "\nYou see:\nAn "+ masterBathRoom.getRoomItem()+"\nA bloody " + masterBathRoom.getRoomItem2() ,"House of Terror",JOptionPane.PLAIN_MESSAGE);
}
else if (menu5==1){
}
else{
JOptionPane.showMessageDialog(null, "Good Bye") ;
}
}
else if (menu2==1){
room ="Grandma's Bedroom";
Room2 bedroom1 = new Room2(room, "Rocking Chair","Window");
JOptionPane.showMessageDialog(null,"You are now in " + bedroom1.getRoomName()+"\nYou see:\nA "+ bedroom1.getRoomItem()+" rocking by itself\nAn open " +bedroom1.getRoomItem2() ,"House of Terror",JOptionPane.PLAIN_MESSAGE);
}
else if(menu2==2){
room = "Alice's Bedroom";
Room2 bedroom2 = new Room2(room, "Doll House","Dresser");
JOptionPane.showMessageDialog(null,"You are now in " + bedroom2.getRoomName()+"\nYou see:\nAn antique "+ bedroom2.getRoomItem()+"\nA pink wooden " +bedroom2.getRoomItem2() ,"House of Terror",JOptionPane.PLAIN_MESSAGE);
}
else{
JOptionPane.showMessageDialog(null, "Good Bye") ;
}
}
else{
JOptionPane.showMessageDialog(null, "Good Bye") ;
}
}
else {
JOptionPane.showMessageDialog(null, "Good Bye") ;
}
}
*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment