I'm having problems with the below code not outputting the JOptionPane.showMessageDialog variable outputs when the if statement conditions are met from JOptionPane.showInputDialog inputs. Would love some help as to why it's not meeting the conditions or outputting the variables, i've also tried println and it still does the same which is just running through each showInputDialog's one after another. Thanks in advance.
public static void main(String[] args) {
String findingCheese = "You arrive to a piece of day old cheese, the scent allures you to go closer";
String findingCrack = "You arrive to a small crack in the wall, it looks like you could fit if you go closer";
String walktoCrack = "You walk right up to the crack and realise you can fit in." + "\n";
walktoCrack = walktoCrack + "You have your front legs in just as you hear someone right behind you";
String eatCheese = "You walk up to the large piece of a cheese and can't resist the urge to eat it." + "\n";
eatCheese = eatCheese + "As you are eating you here someone right behind you";
String walkAway = "As you turn to run away, you realise the owner has been behind you this whole time, with one last wack your sight fades to black";
String cheeseFall = "As you run pass the cheese, the monster in the kitchen slips and falls on the cheese, allowing you to escape. You have beaten the kitchen. Congrats";
String youFit = "You charge into the crack realising you fit exactly, you esacpe as you hear the monster in the kitchen curse you. You have beaten the kitchen. Congrats";
String story = "";
story = story + "Welcome to the choose your own adventure horror story!" + "\n";
story = story + "You are a rat stuck in a kitchen, inside this kitchen is someone that doesn't want you there." + "\n";
story = story + "They want you dead! To escape, you must choose the correct directions and actions to take." + "\n";
story = story + "Good luck rodent.";
JOptionPane.showMessageDialog(null, story);
String direction = JOptionPane.showInputDialog("Enter which direction you want to go between left or right");
if ( direction == "Left" || direction == "left") {
JOptionPane.showMessageDialog(null, findingCheese);
}
if ( direction == "Right" || direction == "right") {
JOptionPane.showMessageDialog(null, findingCrack);
}
String closer = JOptionPane.showInputDialog("Do you want to go closer? yes or no");
if ( closer == "yes" || closer == "yes" && direction == "Left" || direction == "left") {
JOptionPane.showMessageDialog(null, eatCheese);
}
if ( closer == "yes" || closer == "yes" && direction == "Right" || direction == "right") {
JOptionPane.showMessageDialog(null, walktoCrack);
}
if ( closer == "no" || closer == "No") {
JOptionPane.showMessageDialog(null, walkAway);
}
String run = JOptionPane.showInputDialog("Do you want to run away right now? enter yes, if you want to continue forward enter no");
if ( run == "yes" || run == "Yes") {
JOptionPane.showMessageDialog(null, walkAway);
}
else if ( run == "no" || run == "No" && direction == "Left" || direction == "left") {
JOptionPane.showMessageDialog(null, cheeseFall);
}
else if (run == "no" || run == "No" && direction == "right" || direction == "Right") {
JOptionPane.showMessageDialog(null, youFit);
}
}