vendredi 26 février 2021

My code is running its course without user input

For my class online I have to make a Interactive story/Game in java and I am almost done, but something I did to change it is causing all of the dialogue and story to be put on the screen after just the first choice. I am using else ifs and ifs because That is all we have learned so far. Also sorry if it is messy I am still learning it for the most part. Please try to dumb your answers down some. After typing in "Listen" for the first option the entire rest of the story is put in.

import java.util.Scanner;

public class Homework021 {

public static void main(String[] args) {
    Scanner keyboard = new Scanner(System.in);

    String Go = "", Listen, Speak, Fight, A = "", B, C, D;

    System.out.println(" WELCOME TO THE DUNGEON CRAWLER!");
    System.out.println("  ");
    System.out.println(" You are woken up by a large man kicking you in the stomach.\n"
            + "You let a large gasp of air out before proptly getting up in a blurry state.\n"
            + "What will you do?\n" + "(------------------------------------------)\n"
            + "1)Listen to the man (Listen)\n" + "2)Speak to the man (Speak)\n"
            + "3)Throw a punch at the man(Attack) ");
    System.out.print("> ");
    Go = keyboard.next();

    if (Go.equalsIgnoreCase("Listen")) {
        System.out.println(
                "The large man tells you to get ready for your hearing in 2 minutes.\n" + "What will you do?\n"
                        + "(---------------------------------------------------------------------)\n"
                        + "1)Attack(1)\n" 
                        + "2)Sit Down(2) ");
    }
    else if (Go.equalsIgnoreCase("Attack")) {
        System.out.println("While in a bout of confusion you charge the large man to attack.\n"
                + "He grabs you by the throat, picks you up and slams your head into the wall and then onto the ground.\n"
                + "He stomps his massive boot into your skull and then the back of your neck making you fade into a the eternal darkness."
                + "////YOU HAVE DIED. RESART THE GAME.////");
    }
    else if (Go.equalsIgnoreCase("Speak")) {
        System.out.println("You open your mouth to start speaking to the large man.\n"
                + "As you make a sound he balls his fist up and sucker punches you in the stomach dropping you to the floor.\n"
                + "He states 'You speak when spoken to you filthy mutt.' Then tells you to get ready for your hearing\n"
                + "You spit out blood onto the floor and get on all fours. The large man kicks your head into the toilet and your vision gets fuzzy\n"
                + "You slowly start to fade into an unconcious state. As you start to see black the man says 'That's one less piece of trash we have to feed now.'");
        System.out.println("////YOU HAVE DIED. RESTART THE GAME.////");

        A = keyboard.next();

        if (A.equalsIgnoreCase("1"));
        
        System.out.println("The man turns his back to walk out of your cell.\n"
                + "As the man begeins to walk out you grab your blanket and rush him.\n"
                + "You wrap the blanket around his neck and start to strangle him.\n"
                + "The large man begins to turn purple and blue and you keep pulling tighter and tighter.\n"
                + "The man finally falls to his knees then onto his belly.\n"
                + "As the large man lies lifeless on the floor you grab his baton and keys and run out of the cell.\n"
                + "Do you run to the Left or to the Right?\n"
                + "(--------------------------------------------------------------------------)\n"
                + "1)Left\n"
                + "2)Right");
    }
    
    else if (A.equalsIgnoreCase("2"));
    
    System.out.println("You sit down to think about how you ended up there but you are drawing blanks.\n"
            + "You don't even know your name.\n"
            + "You sit on the floor of the cell waiting for the Large man to come back and retreive you.\n"
            + "*2 minutes pass by*\n" + "The large man appears again and tells you to follow him.\n"
            + "As you follow the large man down the hallway of the dungeon you see all the other starving prisoners rotting away in their cells.\n"
            + "You finally arrive to a large room filled with torches and skulls with a man sitting on a throne made of bones\n"
            + "'AHHHHH! My newest warrior!' The man exclaims! 'I cannot wait to see what you can do in the arena!'\n"
            + "'We have your first round tomorrow! Please eat and rest up for your fight! I cant wait to see you in action!'"
            + "What do you do?\n"
            + "(---------------------------------------------------------------------------------------------------------------------)"
            + "1)Go back to your cell to eat and rest(1)\n"
            + "2)Speak(2)"); 
            
    if (A.equalsIgnoreCase("1"));
    System.out.println("You go back to your cell where a tray of food is waiting on you.\n"
            + "You sit down and think about the new life that you now have to pursue.\n"
            + "As you sit eating and thinking the large man comes back and tells you about your new bout."
            + "'Tomorrow you will be fighting Jeebuz, Be ready hes a worthy apponent.'");;
            System.out.println("What will you do?"
                    + "(--------------------------------------------------------------------------------------------------------------)"
                    + "1)Go to sleep(1)"
                    + "2)Beg for forgiveness, and to let you go(2)");
            
            B = keyboard.next();
            
            if (B.equalsIgnoreCase("1"));
            System.out.println("You go to sleep and wake up the next morning.\n"
                    + "The large man comes to your cell and walks you to the preparation room.\n"
                    + "You walk into the room and pick up the all the weapons to inspect them and decide which you want to use."
                    + "You decide to stick with a sword and a shield."
                    + "The large man tells you to enter the arena."
                    + "You enter the arena and find a small man across the way from you. He looks feeble and weak\n"
                    + "You begin to look around and notice hundreds of people chanting and yelling. There are bright lights and flags hanging up\n"
                    + "There are skulls hanging from the ceiling as well as human spines\n"
                    + "What do you do?"
                    + "(--------------------------------------------------------------------------------------------------------------)"
                    + "1)Charge the man across the arena.(Attack)\n"
                    + "2)Wait to see what your oppnent does.(Wait)");
            
     if (A.equalsIgnoreCase("2"));
    System.out.println("You begin to think of your new life you're about to take on.\n"
            + "You open your mouth to speak to the king you get the word 'Where'\n"
            + "As soon as this word comes out of your mouth the large man hits the back of your head with his baton.\n"
            + "You fall onto your face. As you start to see the darkness you hear\n"
            + "'What a shame, I really wanted to see what this man could do."
            + "////YOU HAVE DIED. PLEASE RESTART////");
    
    
    
    
}


}

Aucun commentaire:

Enregistrer un commentaire