Need assistance with a flowchart based on the attached file with code.

package TowerOfTerror;

import javax.swing.ImageIcon;

import javax.swing.JOptionPane;

public class TowerOfTerror {

/**

* @serialField backPack string type array that will hold the strings of

* items

*/

private String backPack[] = new String[16];

/**

* @serialField lastItem int used to keep track of which index to store

* items in

*/

private int lastItem = 0;

private String user;

private boolean alive;

private boolean outside;

/**

* @serialField listOfItems String

*/

private String listOfItems = " ";

//creates image icons for each floor/room and certain events such as death

/**

* @serialField ImageIcon image icons for each room the player enters

*/

private ImageIcon front = new ImageIcon("hotelEntrance.jpg");

private ImageIcon livingRoom = new ImageIcon("livingRoom.jpg");

private ImageIcon bathroom1 = new ImageIcon("bathroom.jpg");

private ImageIcon diningRoom = new ImageIcon("diningRoom.jpg");

private ImageIcon kitchen = new ImageIcon("kitchen.jpg");

private ImageIcon pantry = new ImageIcon("pantry.jpg");

private ImageIcon bedroom1 = new ImageIcon("bedroom1.jpg");

private ImageIcon bedroom2 = new ImageIcon("bedroom2.jpg");

private ImageIcon bathroom2 = new ImageIcon("bathroom2.jpg");

private ImageIcon masterBedroom = new ImageIcon("masterBedroom.jpg");

private ImageIcon masterBathroom = new ImageIcon("masterBathroom.jpg");

private ImageIcon attic = new ImageIcon("attic.jpg");

private ImageIcon basement = new ImageIcon("basement.jpg");

private ImageIcon boilerRoom = new ImageIcon("boilerRoom.jpg");

private ImageIcon storageRoom = new ImageIcon("storageRoom.jpg");

private ImageIcon nearDeath = new ImageIcon("nearDeath.jpg");

private ImageIcon dazedOut = new ImageIcon("dazed.jpg");

private ImageIcon levelFloor = new ImageIcon("floorLevel.jpg");

private ImageIcon elevator = new ImageIcon("elevator.jpg");

private ImageIcon blood = new ImageIcon("blood.jpg");

private ImageIcon dolls = new ImageIcon("dolls.jpg");

private ImageIcon spookyWindow = new ImageIcon("window.jpg");

private ImageIcon spookyChair = new ImageIcon("rockingChair.jpg");

private ImageIcon mirror = new ImageIcon("mirror.jpg");

/**

* This method prompts the user to enter their name and starts a loop that

* continues the game until alive == false or outside == true

*

* @param user the users name

*/

public void startGame() {

//User starts at front door + image displayed

JOptionPane.showMessageDialog(null, "You walk up to the front door \n" , "Main Entrance", JOptionPane.INFORMATION_MESSAGE, front);

//User is asked for their name. Only letters will be accepted

boolean validName = false;

do {

user = JOptionPane.showInputDialog("The door opens before you can even touch it. \n" +

"A strong wind pushes you in and whispers: \n" + "Welcome, what is your beautiful name?");

if ((user.replaceAll("[^A-Za-z]+", "")).length() == 0) {

validName = false;

JOptionPane.showMessageDialog(null, "Invalid input.\n"

+ "Enter a valid input only containing letters.");

} else {

validName = true;

}

} while (validName == false);

/*

The condition alive is set to true and firstFloor() is called

if the user searches certain items they die and the game ends.

if the user gets the key and goes outside game also ends and user wins

*/

alive = true;

while (alive == true && outside == false) {

firstFloor();

}

endGame(); //calls the endGame() if user has died or escaped

}

/**

* checks if a user has a specific item in back pack array

*

* @param item which item is to be checked

* @return hasItem returns true if the item is found in backPack[]

*/

public boolean checkItems(String item) {

boolean hasItem = false;

//Loop checks if any of the indexes contain the string item

for (int i = 0; i < lastItem; i++) {

if (backPack[i].equals(item)) {

hasItem = true;

}

}

return hasItem;

}

/**

* Displays a String showing the list of all items placed in the array

*

* @return listOfItems a String which shows all items collected in the array

*/

public String showInventory() {

//for loopcycles through the items in the backpack array and makes a list

for (int i = 0; i <= lastItem - 1; i++) {

listOfItems = listOfItems + backPack[i] + ",\n";

}

return listOfItems;

}

/**

* firstFloor prompts user to go on the elevator or leave the tower

*

* @see options array with the different user options

*/

private void firstFloor() {

//User is asked which floor they want to go to

//option is assigned to int userOption

JOptionPane.showMessageDialog(null, " ", " ", JOptionPane.INFORMATION_MESSAGE, levelFloor);

Object[] options = {"Leave the Tower", "Go to the Elevator"};

int userOption = JOptionPane.showOptionDialog(null,

"You are currently on the first floor " + user + ", you are free to explore..."

+ "\nWhere would you like to go?",

"First Floor",

JOptionPane.YES_NO_CANCEL_OPTION,

JOptionPane.QUESTION_MESSAGE,

null,

options,

options[1]);

//if statement executes different decisions based on checking

//userOption, calls a method based on the room the user chose.

if (userOption == 0) {

//Calls checkItems method with a specific item to check if the user has it

if (checkItems("Key to Front Door") == true) {

JOptionPane.showMessageDialog(null, "You unlocked the front door and run for your life. \n"

+ "You lived to see another day! Congratulations.");

outside = true;

} else {

JOptionPane.showMessageDialog(null, "The door is locked and you do not have the key. "

+ "Survive and find the BLUE key. Good luck...");

firstFloor();

}

} else if (userOption == 1) {

goToElevator();

}

}

/**

* goToElevator user chooses which if the 13 floors to go to

*/

public void goToElevator() {

/**

* @param options Each level is assigned a position in the array. Once

* selected the user will be taken to a different method

*/

JOptionPane.showMessageDialog(null, " ", " ", JOptionPane.INFORMATION_MESSAGE, elevator);

Object[] options = {"Basement", "F(1)", "F(2)", "F(3)", "F(4)", "F(5)",

"F(6)", "F(7)", "F(8)", "F(9)", "F(10)", "F(11)", "Attic"};

int userOption = JOptionPane.showOptionDialog(null, user + " pick a floor, any floor if you dare...",

"Elevator",

JOptionPane.YES_NO_CANCEL_OPTION,

JOptionPane.QUESTION_MESSAGE,

null,

options, null);

switch (userOption) {

case 0:

goToBasement();

break;

case 1:

firstFloor();

break;

case 2:

goToLivingRoom();

break;

case 3:

goToKitchen();

break;

case 4:

goToDiningRoom();

break;

case 5:

goToPantry();

break;

case 6:

goToGuestBathroom1();

break;

case 7:

goToBedroom1();

break;

case 8:

goToGuestBathroom2();

break;

case 9:

goToGuestBedroom2();

break;

case 10:

goToMasterBathroom();

break;

case 11:

goToMasterBedroom();

break;

case 12:

goToAttic();

break;

}

}

/**

* @serialData goToBasment user is prompted to decide if they want to go to

* one of the 2 rooms or back on the elevator.

*/

public void goToBasement() {

//User is prompted to decide if they want to go to another room or

//check the item in the current room.

JOptionPane.showMessageDialog(null,"The elevator goes down to the basement. \n"

+ "You walk out of the elevator and enter "

+ "a cold old basement\nThere are two paths, a boiler room and a "

+ "storage room. \nDo you want to go to one of these rooms or"

+ " return to the elevator?",

"Basement", JOptionPane.INFORMATION_MESSAGE, basement);

Object[] options = {"Return to Elevator",

"Go to Boiler Room", "Go to Storage Room"};

int userOption = JOptionPane.showOptionDialog(null,

"Where would you like to go?",

"Basement",

JOptionPane.YES_NO_CANCEL_OPTION,

JOptionPane.QUESTION_MESSAGE,

null,

options,

options[2]);

//Send To according room that was chosen using if else staements

if (userOption == 0) {

goToElevator();

} else if (userOption == 1) {

goToBoilerRoom();

} else if (userOption == 2) {

goToStorageRoom();

}

}

/**

* user is prompted to explore an item or leave the room, the user cannot

* add the same item to their backpack twice

*/

public void goToBoilerRoom() {

JOptionPane.showMessageDialog(null, "You walk into"

+ " the boiler room. \nThere is a tool box in the middle of the room.",

"Boiler Room", JOptionPane.INFORMATION_MESSAGE, boilerRoom);

//do-while loop starts and continues until user decides to move to

//another room, cycle becomes 1 if user chooses to leave

int cycle = 0;

do {

Object[] options = {"Check the Tool Box", "Go to Elevator", "Go to Storage Room"};

int userOption = JOptionPane.showOptionDialog(null,

"Do you want to check the tool box or do you want to "

+ "leave the room?",

"Basement (Boiler Room)",

JOptionPane.YES_NO_CANCEL_OPTION,

JOptionPane.QUESTION_MESSAGE,

null,

options,

options[2]);

if (userOption == 0) {

/* checkItems method is called to check if the use already has

the item*/

if (checkItems("Tool Box") == false) {

JOptionPane.showMessageDialog(null, "You open the tool box and find fake used vampire fangs inside."

+ "\nTool box was added to your backpack");

//if user doesn't alreayd have item, the item is added to

//the next index (lastItem) in the array "

backPack[lastItem] = "Tool Box";

lastItem++;

} else {

JOptionPane.showMessageDialog(null, "Item was previously checked.");

}

} else if (userOption == 1) {

cycle++;

goToElevator();

} else {

cycle++;

goToStorageRoom();

}

} while (cycle == 0);

}

/**

* goToStorageRoom user is prompted to explore an item or leave the room,

* the user cannot add the same item to their backpack twice

*/

public void goToStorageRoom() {

JOptionPane.showMessageDialog(null, "You walked into"

+ " the storage room. \nYou see a wooden chest in the left corner of the room.",

"Storage Room", JOptionPane.INFORMATION_MESSAGE, storageRoom);

//Loop cotinues until cycle is broken by user leaving the room cycle becomes 1

int cycle = 0;

do {

Object[] options = {"Open the Chest", "Return to the Elevator", "Boiler Room",};

int userOption = JOptionPane.showOptionDialog(null,

"Would you like to see what's inside the chest? Or do you want to "

+ "leave the room?",

"Basement (Storage Room)",

JOptionPane.YES_NO_CANCEL_OPTION,

JOptionPane.QUESTION_MESSAGE,

null,

options,

options[2]);

if (userOption == 0) {

//User finds the key that opens the attic

if (checkItems("Key to Attic") == false) {

JOptionPane.showMessageDialog(null, "You open the chest. Inside there is a "

+ "RED key attached to a black lanyard. \nThe key was added to your backpack");

backPack[lastItem] = "Key to Attic";

lastItem++;

} else {

JOptionPane.showMessageDialog(null, "Item was previously checked.");

}

} else if (userOption == 1) {

cycle++;

goToElevator();

} else {

cycle++;

goToBoilerRoom();

}

} while (cycle == 0);

}

/**

* goToLivingRoom user is prompted to explore an item or leave the room, the

* user cannot add the same item to their backpack twice

*/

public void goToLivingRoom() {

JOptionPane.showMessageDialog(null, "The elevator "

+ "moves to the 2nd floor, the living room. \nYou walk into"

+ " the living room, there is dust everywhere. \nThere is a small Chest"

+ " levitating in the air at eye level", "Living Room", JOptionPane.INFORMATION_MESSAGE, livingRoom);

//cycle is changed to one and the loop ends when the user decides to

//leave the room.

int cycle = 0;

do {

Object[] options = {"Open the Chest",

"Go Back to Elevator",};

int userOption = JOptionPane.showOptionDialog(null,

"Would you like to open the Chest \nor do you want to go "

+ "back to the Elevator? ", "Living Room",

JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,

null, options, options[1]);

if (userOption == 0) {

//checkItems method is called, if the user has already checked

//this item then they will not be able to add the same item

//to the backpack

if (checkItems("Chest") == false) {

JOptionPane.showMessageDialog(null, "You open the Chest. "

+ "A tiny spider crawls out and kisses your hand then disappears into thin air!"

+ "\nThe Chest was added to your backpack.");

//lastitem++ increment is so that the items can be added

//to the array in the appropriate index.

backPack[lastItem] = "Chest";

lastItem++;

} else {

JOptionPane.showMessageDialog(null, "Item was previously checked.");

}

} else {

//cycle variable becomes 1, to end the loop, user goes back to

//elevator

cycle++;

goToElevator();

}

} while (cycle == 0);

}

/**

* goToKitchen user is prompted to explore an item or leave the room, the

* user cannot add the same item to their backpack twice

*/

public void goToKitchen() {

JOptionPane.showMessageDialog(null, "The elevator moves"

+ " to the kitchen...\nYou walk into the kitchen and see "

+ "cabinets and a refrigerator.", "Kitchen",

JOptionPane.INFORMATION_MESSAGE, kitchen);

int cycle = 0;

do {

//Prompts the user to decide where they want to go next, or if they want

//to check the items in the kitchen

Object[] options = {"Open the Refrigerator",

"Open the Cabinet", "Go Back to the Elevator"};

int userOption = JOptionPane.showOptionDialog(null,

"Do you want to check what's inside the refrigerator,\nopen the cabinet,"

+ " or go back to the Elevator?",

"Kitchen",

JOptionPane.YES_NO_CANCEL_OPTION,

JOptionPane.QUESTION_MESSAGE,

null,

options,

options[2]);

//Outcome depends on user input

if (userOption == 0) {

JOptionPane.showMessageDialog(null, "You open the refrigerator and "

+ "a white dust is thrown in your face.\n"

+ "You do not have time to react before you drop to the floor and die. \nThe powder "

+ "might have been anthrax...");

backPack[lastItem] = "Refrigerator";

lastItem++;

cycle++;

alive = false;

} else if (userOption == 1) {

if (checkItems("Cabinet") == false) {

JOptionPane.showMessageDialog(null, "As soon as you open the "

+ "cabinet forks and spoons jump out!\nThe utensils dance around your head,"

+ " you become extremely dizzy. \n Cabinet was "

+ "added to your backpack. ", " ", JOptionPane.INFORMATION_MESSAGE, dazedOut);

backPack[lastItem] = "Cabinet";

lastItem++;

} else {

JOptionPane.showMessageDialog(null, "Item was previously checked.");

}

} else {

cycle++;

goToElevator();

}

} while (cycle == 0);

}

/**

* goToDiningRoom user is prompted to decide if they want to explore item or

* travel to another room

*/

public void goToDiningRoom() {

JOptionPane.showMessageDialog(null, "You walk into the dining room, "

+ "There is a large table but \nYou notice the huge chandelier hanging above your head instead\n",

"Dining Room ", JOptionPane.INFORMATION_MESSAGE, diningRoom);

int cycle = 0;

do {

//Prompts user selection

Object[] options = {"Examine the Chandelier",

"Go to Elevator",};

int userOption = JOptionPane.showOptionDialog(null,

"Do you want to take look at the Chandelier or "

+ "return to the elevator? ",

"Dining Room",

JOptionPane.YES_NO_OPTION,

JOptionPane.QUESTION_MESSAGE,

null,

options,

options[1]);

if (userOption == 0) {

if (checkItems("Chandelier") == false) {//shows user the item text if they checked the item

JOptionPane.showMessageDialog(null, "You walk over and take a "

+ "closer look at the Chandelier. \nThe Chandelier starts swinging but does not fall."

+ "\nThe Chandelier is added to the backpack. ");

backPack[lastItem] = "Chandelier";

lastItem++;

} else {

JOptionPane.showMessageDialog(null, "Item was previously checked.");

}

} else {

cycle++;

goToElevator();

}

} while (cycle == 0);

}

/**

* goToPantry user is prompted to decide if they want to explore the items

* or travel to another room

*/

public void goToPantry() {

JOptionPane.showMessageDialog(null, "You look in the pantry and see"

+ " a recipe box and a broom.", "Pantry ", JOptionPane.INFORMATION_MESSAGE, pantry);

int cycle = 0;

//Promtps user input same as previous methods

do {

Object[] options = {"Open the Recipe Box",

"Observe the Broom", "Go Back to the Elevator"};

int userOption = JOptionPane.showOptionDialog(null,

"Do you want to open the recipe box, observe the broom, or go"

+ " back to the elevator?", "Pantry",

JOptionPane.YES_NO_OPTION,

JOptionPane.QUESTION_MESSAGE,

null,

options,

options[1]);

//Outcome depends on which item is selected

if (userOption == 0) {

if (checkItems("Recipe") == false) {

JOptionPane.showMessageDialog(null, "You open the box and find a recipe "

+ "for eternal life written down." + "\nYou doubt it is real so you disregard the recipe."

+ "\nThe recipe box is added to your backpack.");

backPack[lastItem] = "Recipe";

lastItem++;

} else {

JOptionPane.showMessageDialog(null, "Item was previously checked.");

}

} else if (userOption == 1) {

if (checkItems("Broom") == false) {

JOptionPane.showMessageDialog(null, "You try to grab the broom "

+ "\nbut it flies up in the air" + " hitting your nose!" +"\nOUCH!");

backPack[lastItem] = "Broom";

lastItem++;

} else {

JOptionPane.showMessageDialog(null, "Item was previously checked.");

}

} else {

cycle++;

goToElevator();

}

} while (cycle == 0);

}

/**

* goToGuestBathroom user is prompted to decide if they want to explore item

* or travel to another room

*

*/

public void goToGuestBathroom1() {

JOptionPane.showMessageDialog(null, "You walk into guest bathroom 1.",

"Guest Bathroom 1", JOptionPane.INFORMATION_MESSAGE, bathroom1);

int cycle = 0;

do {

Object[] options = {"Check the Shower",

"Observe the Mirror", "Return to Elevator"};

int userOption = JOptionPane.showOptionDialog(null, "Do you want to examine the "

+ "mirror, examine the shower, or go back to the elevator?",

"Guest Bathroom 1",

JOptionPane.YES_NO_OPTION,

JOptionPane.QUESTION_MESSAGE,

null,

options,

options[1]);

//Different message appears based on what item the user chose

if (userOption == 0) {

if (checkItems("Shower Curtain") == false) {

JOptionPane.showMessageDialog(null, "You pull back the shower curtain."

+ "\nThe shower turns on and you hear a soft voice singing BUT NO ONE IS THERE!" + "\nYou add"

+ " the shower curtain to your backpack.");

backPack[lastItem] = "Shower Curtain";

lastItem++;

} else {

JOptionPane.showMessageDialog(null, "Item was previously checked.");

}

} else if (userOption == 1) {

JOptionPane.showMessageDialog(null, "Always think twice before looking in a mirror..."

, "Mirror", JOptionPane.INFORMATION_MESSAGE, mirror);

JOptionPane.showMessageDialog(null, "You look in the mirror and see "

+ "a face dripping blood." + "\nYou get sucked into the mirror and die."

+ "\nA mirror is "

+ "added to your backpack.");

backPack[lastItem] = "Mirror";

lastItem++;

cycle++;

alive = false;

} else {

cycle++;

goToElevator();

}

} while (cycle == 0);

}

/**

* goToBedroom1 user is prompted to decide if they want to explore item or

* travel to another room

*/

public void goToBedroom1() {

JOptionPane.showMessageDialog(null, "You walk into guest bedroom 1.", ""

+ "Guest Bedroom 1 ", JOptionPane.INFORMATION_MESSAGE, bedroom1);

int cycle = 0;

do {

//Prompts user input

Object[] options = {"Look out the Window", "Observe the Rocking Chair",

"Go to Elevator"};

int userOption = JOptionPane.showOptionDialog(null,

"Do you want to take a look out the window, "

+ "examine the rocking chair, or go back to the elevator?",

"Guest Bedroom 1",

JOptionPane.YES_NO_CANCEL_OPTION,

JOptionPane.QUESTION_MESSAGE,

null,

options,

options[2]);

if (userOption == 0) {

if (checkItems("Window") == false) {

JOptionPane.showMessageDialog(null, "You peer out the window and "

+ "see a little boy on the swing. \nYou look away for a second and he is gone..."

+ "\nYou add window to your backpack.", " ",

JOptionPane.INFORMATION_MESSAGE, spookyWindow);

backPack[lastItem] = "Window";

lastItem++;

} else {

JOptionPane.showMessageDialog(null, "Item was previously checked.");

}

} else if (userOption == 1) {

if (checkItems("Rocking Chair") == false) {

JOptionPane.showMessageDialog(null, "You walk over to the chair debating whether to sit or not. "

+ "\nYou extened your hand to touch it but the chair starts rocking by itself."

+ "\nYou add rocking Chair to your backpack.",

"Guest Bedroom ", JOptionPane.INFORMATION_MESSAGE,

spookyChair);

backPack[lastItem] = "Rocking Chair";

lastItem++;

} else {

JOptionPane.showMessageDialog(null, "Item was previously checked.");

}

} else {

cycle++;

goToElevator();

}

} while (cycle == 0);

}

/**

* goToGuestBathroom2 user is prompted to decide if they want to explore

* item or travel to another room

*/

public void goToGuestBathroom2() {

JOptionPane.showMessageDialog(null, "You walk into guest bathroom 2.",

"Guest Bathroom 2", JOptionPane.INFORMATION_MESSAGE, bathroom2);

int cycle = 0;

do {

Object[] options = {"Check the Toilet",

"Open the Cupboard", "Return to Elevator"};

int userOption = JOptionPane.showOptionDialog(null, "Do you want to examine the "

+ "toilet, open the cupboard, or go back to the elevator?",

"Guest Bathroom 2",

JOptionPane.YES_NO_OPTION,

JOptionPane.QUESTION_MESSAGE,

null,

options,

null);

//Different message appears based on what item the user chose

if (userOption == 0) {

if (checkItems("Toilet") == false) {

JOptionPane.showMessageDialog(null, "You open the toilet and "

+ "see a dead rat inside."

+ "\nYou feel disgusted and pass away. "

+ "\nToilet is added to your backpack.");

backPack[lastItem] = "Toilet";

lastItem++;

cycle++;

alive = false;

}

} else if (userOption == 1) {

if (checkItems("Mouthwash") == false) {

JOptionPane.showMessageDialog(null, "You open the cupboard"

+ "\nand find your favorite mouthwash." + "\nLuckily you needed to buy some later tonight."

+ "\nYou add the mouthwash to your backpack.");

backPack[lastItem] = "Mouthwash";

lastItem++;

} else {

JOptionPane.showMessageDialog(null, "Item was previously checked.");

}

} else {

cycle++;

goToElevator();

}

} while (cycle == 0);

}

/**

* goToGuestBedroom2 user is prompted to decide if they want to

* explore item or travel to another room

*/

public void goToGuestBedroom2() {

JOptionPane.showMessageDialog(null, "You walk into guest bedroom 2.", ""

+ "Guest Bedroom 2 ", JOptionPane.INFORMATION_MESSAGE, bedroom2);

int cycle = 0;

do {

//Prompts user input

Object[] options = {"Observe the Doll House", "Look in the Dresser",

"Go to Elevator"};

int userOption = JOptionPane.showOptionDialog(null,

"Do you want to observe the doll house, look in the dresser, "

+ "or go back to the elevator? ",

"Guest Bedroom 2",

JOptionPane.YES_NO_CANCEL_OPTION,

JOptionPane.QUESTION_MESSAGE,

null,

options,

options[2]);

if (userOption == 0) {

if (checkItems("Doll House") == false) {

JOptionPane.showMessageDialog(null, "You look in the doll house"

+ "\nand the dolls start moving on their own."

+ " \nYou add the doll house to your backpack.", " ",

JOptionPane.INFORMATION_MESSAGE, dolls);

backPack[lastItem] = "Doll House";

lastItem++;

} else {

JOptionPane.showMessageDialog(null, "Item was previously checked.");

}

} else if (userOption == 1) {

if (checkItems("Dresser") == false) {

JOptionPane.showMessageDialog(null, "You open the dresser and"

+ "\na ghost comes out and flies through your heart."

+ "\nYou feel like gelatin but manage to live. \nDresser is "

+ "added to your backpack.",

"Guest Bedroom ", JOptionPane.INFORMATION_MESSAGE,

nearDeath);

backPack[lastItem] = "Dresser";

lastItem++;

} else {

JOptionPane.showMessageDialog(null, "Item was previously checked.");

}

} else {

cycle++;

goToElevator();

}

} while (cycle == 0);

}

/**

* goToMasterBathroom user is prompted to decide if they want

* to explore item or travel to another room

*/

public void goToMasterBathroom() {

JOptionPane.showMessageDialog(null, "You walk into "

+ "the master bathroom" + "\nYou see a plugged in nightlight and multiple sink drawers",

"Master Bathroom", JOptionPane.INFORMATION_MESSAGE, masterBathroom);

int cycle = 0;

do {

Object[] options = {"Examine the Nightlight",

"Check the Drawer ", "Return to Elevator"};

int userOption = JOptionPane.showOptionDialog(null, "Do you want to examine the "

+ "Nightlight, check the Drawer, or go back to the elevator?",

"Master Bathroom",

JOptionPane.YES_NO_OPTION,

JOptionPane.QUESTION_MESSAGE,

null,

options,

options[1]);

//Different message appears based on what item the user chose

if (userOption == 0) {

if (checkItems("Nightlight") == false) {

JOptionPane.showMessageDialog(null, "You walk up to the Nightlight." +

"\nTo your surprise, it still works!" +

"\nYou try to unplug it and end up getting electrocuted..."

+ "\nIt was either the Nightlight's life or yours. May you rest in piece.");

backPack[lastItem] = "Nightlight";

lastItem++;

cycle++;

alive = false;

}

} else if (userOption == 1) {

if (checkItems("Tooth floss") == false) {

JOptionPane.showMessageDialog(null, "You walk up to sink and notice it is also has storage drawers."

+ "\nYou pick a random drawer to open and brace yourself for something to pop out."

+ "\nThe drawer only contained tooth floss..." +

"\nThe tooth floss was added to your backpack");

backPack[lastItem] = "Tooth floss";

lastItem++;

} else {

JOptionPane.showMessageDialog(null, "Item was previously checked.");

}

} else {

cycle++;

goToElevator();

}

} while (cycle == 0);

}

/**

*goToMasterBedroom user is prompted to decide if they want to

* explore item or travel to another room

*

*/

public void goToMasterBedroom() {

JOptionPane.showMessageDialog(null, "You walk into the master bedroom.", ""

+ "Master Bedroom", JOptionPane.INFORMATION_MESSAGE, masterBedroom);

int cycle = 0;

do {

//Prompts user input

Object[] options = {"Open the Jewelery Box...", "Go to Elevator"};

int userOption = JOptionPane.showOptionDialog(null, "There is a glowing jewelery box "

+ "on the nightstand.\nDo you want to see what's inside"

+ " or return to the elevator?",

"Master Bedroom",

JOptionPane.YES_NO_CANCEL_OPTION,

JOptionPane.QUESTION_MESSAGE,

null,

options,

options[1]);

if (userOption == 0) {

JOptionPane.showMessageDialog(null, "You open the Jewelry box and find the cursed diamond." +

"\nYour life slowly withers away.");

backPack[lastItem] = "Diamond";

lastItem++;

cycle++;

alive = false;

} else {

cycle++;

goToElevator();

}

} while (cycle == 0);

}

/**

* goToAttic user is prompted to decide if they want to explore

* item or travel to another room

*/

public void goToAttic() {

//if the user does not have the key to the attic in the backpack, they

//cannot enter the attic

if (checkItems("Key to Attic") == false) {

JOptionPane.showMessageDialog(null, "You try to go into the attic but"

+ "\nit's locked, find the RED key to unlock the attic door.");

goToElevator();

} else {

JOptionPane.showMessageDialog(null, "The elevator"

+ " goes up to the top floor, the attic. \nYou take out the "

+ "red key and turn the lock, you walk into"

+ " the attic. \nYou see a chest covered in cobwebs...",

"Attic", JOptionPane.INFORMATION_MESSAGE, attic);

int cycle = 0;

do {

Object[] options = {"Open the Chest", "Return to the Elevator",};

int userOption = JOptionPane.showOptionDialog(null,

"Would you like to see what's inside the chest? Or do you want to "

+ "go back to the elevator?",

"Attic",

JOptionPane.YES_NO_CANCEL_OPTION,

JOptionPane.QUESTION_MESSAGE,

null,

options,

null);

if (userOption == 0) {

if (checkItems("Key to Front Door") == false) {

//User finds the key to the front door

JOptionPane.showMessageDialog(null, "You open the chest and find a "

+ "shiny BLUE key. \nYou add the "

+ "key to your backpack.");

backPack[lastItem] = "Key to Front Door";

lastItem++;

} else {

JOptionPane.showMessageDialog(null, "Item was previously checked.");

}

} else {

cycle++;

goToElevator();

}

} while (cycle == 0);

}

}

/**

* endGame method is called if the user dies or leaves the house alive

* showInventory is called to display a list of all items found

*/

public void endGame() {

//Method clearly expresses to the user that the game is over

//message depends on if the user died or won by finding the two keys

if (outside == true) {

JOptionPane.showMessageDialog(null, "You get as far as you can from the "

+ "tower and decide never to return. \nYou found the following "

+ "items in your backpack: \n" + showInventory());

}

if (alive == false) {

JOptionPane.showMessageDialog(null, "YOU DIED... \nThe following "

+ "items are in your backpack: \n" + showInventory(), "DEATH",

JOptionPane.INFORMATION_MESSAGE, blood);

}

}