Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.JOptionPane;
- public class Project {
- static boolean quit = false;
- static String place = "start";
- public static String q(String m) {
- String s = JOptionPane.showInputDialog(m);
- return s;
- }
- public static void m(String s) {
- JOptionPane.showMessageDialog(null, s);
- }
- public static void main(String [] args) {
- while(!quit) {
- if (place.equals("start")) {
- start();
- } else if (place.equals("dungeon")) {
- dungeon();
- } else if (place.equals("forest")) {
- forest();
- } else if (place.equals("school")) {
- school();
- } else if (place.equals("cave")) {
- cave();
- } else if (place.equals("dungeon2")) {
- dungeon2();
- } else if (place.equals("forest2")) {
- forest2 ();
- } else if (place.equals("forest3")) {
- forest3 ();
- } else if (place.equals("house")) {
- house();
- } else if (place.equals("dead")) {
- m("You are dead.");
- quit = true;
- } else if (place.equals("win")) {
- m("You won! Congratulations!");
- quit = true;
- }
- }
- }
- public static void start() {
- String choice = q ("Welcome, you have reached the start of your adventure!\n"+
- "Which path would you like to take?\n"+
- "You may choose to go to the [d]ungeon, [f]orest, [s]chool, [h]ouse, or the [c]ave.");
- if (choice.equals("d")) {
- place = "dungeon";
- } else if (choice.equals("f")) {
- place = "forest";
- } else if (choice.equals("s")) {
- place = "school";
- } else if (choice.equals("c")) {
- place = "cave";
- } else if (choice.equals("h")) {
- place = "house";
- }
- }
- public static void house() {
- String choice = q("Here you are at a scary house.\n"+
- "There are 2 doors, 1 lead to death, and the other leads to money.\n"+
- "Which door do you choose?\n[1], [2]");
- if (choice.equals("1")) {
- m("You open the door and walk in.\n"+
- "Suddenly the floor disappears and you fall to your death.\n");
- place = "dead";
- } else if (choice.equals("2")) {
- m("You open the door and the shiny gold and treasure is sitting in front of you!\n"+
- "you grab as much as u can and get out.\n");
- place = "win";
- }
- }
- public static void dungeon() {
- String choice = q("You have arrived in the dungeon.\n"+
- "You walk in and see a scary monster!.\n"+
- "Fight the monster with your powers\n[y]es or [n]o");
- if (choice.equals("y")) {
- double fight = Math.random();
- if (fight > 0.7) {
- m("The monster destroys you and you have died a painful death");
- place = "dead";
- } else {
- m("A friend appears to help you kill the monster and you proceed onward");
- place = "dungeon2";
- }
- } else if (choice.equals("n")) {
- m("you run away and pee your pants.");
- place = "start";
- }
- }
- public static void dungeon2() {
- String choice = q("You walk farther in the dungeon and notice the treasure.\n"+
- "You walk in to take the treasure when the protector of the treasure appears!\n"+
- "There is a dragon! Fight it?\n[y]es or [n]o");
- if (choice.equals("y")) {
- double fight = Math.random();
- if (fight > 0.7) {
- m("The dragon burns you to a crisp");
- place = "dead";
- } else {
- m("You're friend runs away, but you become a man and slay the dragon!\nYou grab the treasure!");
- place = "win";
- }
- } else if (choice.equals("n")) {
- m("You run away and don't get any treasure.");
- place = "start";
- }
- }
- public static void forest() {
- String choice = q("It is dark in the forest, and a wild bear appears!\n"+
- "The bear wants some porridge.\n Will you make the bear food?\n[y]es or [n]o");
- if (choice.equals("y")) {
- double fight = Math.random();
- if (fight > 0.5) {
- m("The porridge was just right, so the bear let's u go past.");
- place = "forest2";
- } else {
- m("The porridge was too cold, the bear mauls you to death");
- place = "dead";
- }
- } else if (choice.equals("n")) {
- m("The bear is hungry and mad, so he chases after you.");
- place = "dead";
- }
- }
- public static void forest2() {
- String choice = q("You pass the bear who is peacefully eating his porridge.\n"+
- "You continue on your journey through the haunted forest. While walking, a wild pepe appears!\n"+
- "The pepe wants to beat you up, do you allow this to happen?\n[y]es or [n]o");
- if (choice.equals("y")) {
- m("You become bruised badly, but you survive.");
- place = "forest3";
- } else if (choice.equals("n")) {
- m("You attempt to run away, but pepe jumps towards you and beats you up anyways.");
- place = "dead";
- }
- }
- public static void forest3() {
- String choice = q("You've survived a pepe attack and passed a bear!\n"+
- "Congratulations, this is your final test.\n"+
- "You see the money in front of you, but there is a river in the way.\n"+
- "Do you try to pass the river, or give up?\n[y]es or [n]o");
- if (choice.equals("y")) {
- m("You think for a long time for a plan to cross.\n"+
- "You notice a large piece of wood and use it to build a boat.\n"+
- "You cross the large river with your boat and get all the money!");
- place = "win";
- } else if (choice.equals("n")) {
- m("You decide not to try and cross because you don't want to risk drowning.\n"+
- "Suddenly, there is a strong wind that pushes you into the river, and you drown anyways.\n");
- place = "dead";
- }
- }
- public static void school() {
- String choice = q("You arrive at the Charter School of Wilmington!\n"+
- "Zombie Mr. Kramer appears and he wants your brains.\nHe asks you a question:\n"+
- "Who is the best teacher at CSW?");
- if (choice.equals("Mr. Kramer")) {
- m("Zombie Mr. Kramer allows you to go further into the school\n"+
- "In the computer science class, you find millions of dollars!\n"+
- "Victory!");
- place = "win";
- } else {
- m("The zombie is mad and eats you!");
- place = "dead";
- }
- }
- public static void cave() {
- String choice = q("you arrive at a spooky cave!\n"+
- "There are ninja turtles guarding your girlfriend!\n"+
- "Save your girlfriend and fight?\n[y]es or [n]o");
- if (choice.equals("y")) {
- double fight = Math.random();
- if (fight > 0.6) {
- m("The ninja turtles team up and slice you in half");
- place = "dead";
- } else {
- m("You fight with all your might and beat the turtles!\nYou save your girlfriend!");
- place = "win";
- }
- } else if (choice.equals("n")) {
- m("you run away and leave your girlfriend to die!");
- place = "start";
- }
- }
- }
Add Comment
Please, Sign In to add comment