Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
(Java)代码在两次之后停止_Java - Fatal编程技术网

(Java)代码在两次之后停止

(Java)代码在两次之后停止,java,Java,在我正在制作的一个游戏中,我有4个门,都有if和else if。但是代码只允许前两扇门,我不知道为什么 编辑:非常抱歉!我问错了问题。以下是重新表述的内容: /** * Write a description of class GameE02 here. * * @Aakarsh * @1.0 (18 October 2015) */ import java.util.*; //System.out.print('\f'); clear everything. pu

在我正在制作的一个游戏中,我有4个门,都有if和else if。但是代码只允许前两扇门,我不知道为什么

编辑:非常抱歉!我问错了问题。以下是重新表述的内容:

/**
 * Write a description of class GameE02 here.
 * 
 * @Aakarsh
 * @1.0 (18 October 2015)
  */

 import java.util.*;


 //System.out.print('\f'); clear everything.


 public class GameE02
 {

 public static void main(String [] args) throws InterruptedException{

   Scanner reader = new Scanner(System.in);


   int i1, i2, i3, i4, i5, i6, i7, i8, i9;
   int o1, o2, o3, o4, o5, o6, o7, o8, o9;
   String s1, s2, s3, s4, s5, s6, s7, s8, s9;
   boolean loop = false;
   boolean thugloop = false; //thug hop scotch loop
   int counter = 1; //staircase counter
   int counter2 = 1; //thug hopscotch counter
   //somewhere, add in a never ending loop cycle (game over basically). Secret code required to end the game.


   System.out.println("Do you want to play a game? (y = yes, n = no)");

   s1 = reader.next();


   System.out.println("You walk into a room, there are 5 doors on the left one room on the right, you look at the room; do you wish to enter?");
   s2 = reader.next();


   //Begin the stairchase choice - Step 1 of the game.




   if(s2.equals("y")){

       Thread.sleep(1000);
       System.out.println("You have entered the room, you see a spiral staircase going up or chance to exit; you look at the staircase, do you wish to enter?");
       s3 = reader.next();
       Thread.sleep(1000);
       loop = true;

        System.out.println("You walk up the stairs, but you shockingly see yourself back in the same room, same position, climb again?");
       s3 = reader.next();  //begin the staircase loop

       while(loop==true){



       if(s3.equals("y")){
            System.out.println("You walk up the stairs, but you shockingly see yourself back in the same room, same position, climb again?");
       s3 = reader.next();
      counter++;

        }else if(s3.equals("n")){

            System.out.println("You have chosen not to climb the staircase.");

            loop=false;
            break;
        }


    }  //loop ends here.


    Thread.sleep(1000);

    System.out.println("You are frightened and you walk back and see six doors, pick one (1, 2, 3, 4, 5, 6)");
    //pun - pick one
    s5=reader.next();

    if(s5.equals("1")){

        System.out.println("Good, you understood the pun; you may still have a chance at surviving.");
        Thread.sleep(1000);


        //add in the rest of the code here.


    }else{

        System.out.println("Damn, you really suck at reading - what are you, an AP Computer Science student? I said: 'six doors.. pick ONE...");
        Thread.sleep(3950);
        System.out.println("Since you lost that, I need to put you in the maze, sorry!");
    }


    }  if(s2.equals("n")){
        counter=0;
       Thread.sleep(1000); 

        System.out.println("You see four doors, which one do you pick? (1, 2, 3, 4)");
        i1 = reader.nextInt(); //door choice number. 

        if(i1 == 1){
            Thread.sleep(500);
            System.out.println("You go inside a dungeon, and meet a skeleton there; ");
            Thread.sleep(1000);
            System.out.println("You  talk to the skeleton; Press 'y' if you want to play thug hop-scotch, or 'n' if you want to fight.");
            s4=reader.next();
            if(s4.equals("y")){
                Thread.sleep(1000);
                System.out.println("Enter some 5 (after this) from 1 to maximum-17 (inclusive) individually. Repeats are allowed.");
                i4=reader.nextInt();
                i5=reader.nextInt();
                i6=reader.nextInt();
                i7=reader.nextInt();
                i8=reader.nextInt();
                int sumhop = i4 + i5 + i6 + i7 + i8;
                System.out.println("Through a complex algorithm your sequence of numbers read " + sumhop);
                Thread.sleep(3700);
                System.out.println("Fortunately (or unforunately) the thug you were playing hopscotch against was confident so he had this program generate him a random number.");
                Thread.sleep(2500);
                int randomhop = 3 + (int)(Math.random()*84); //thug hop scotch random.

                System.out.println("His random number generated was: " + randomhop);

                Thread.sleep(1000);
                if(sumhop < randomhop){

                System.out.println("Seriously? READ CAREFULLY - When asking the question, I told you: 'Enter 5 SUM-numbers-MAXIMUM'.");
                Thread.sleep(3000);
                System.out.println("You should have done 17*5  = 85 to outbeat the thug");
                Thread.sleep(3000);
                System.out.println("Anyway, time to do battle with the thug skeleton!");
                counter2=0;


            } else if(sumhop > randomhop){
                System.out.println("Woah, you beat the thug; but now the thug is angry and he won't rest until he beats you.");
                Thread.sleep(2000);
                thugloop = true;
                  System.out.println("Pick your numbers again");

                  o4=reader.nextInt();
                o5=reader.nextInt();
                o6=reader.nextInt();
                o7=reader.nextInt();
                o8=reader.nextInt();
                int sumhop2 = o4+o5+o6+o7+o8;
                  int angrythug = 3 + (int)(Math.random()*85); 

                while(thugloop == true){



                  if(sumhop2>angrythug){
                      counter2++;
                      Thread.sleep(1000);
                      System.out.println("The thug picked: " + angrythug + " .Woah, you are really good at this!");
                      Thread.sleep(1500);
                       System.out.println("But the thug is getting angrier. Pick again!");
                         o4=reader.nextInt();
                o5=reader.nextInt();
                o6=reader.nextInt();
                o7=reader.nextInt();
                o8=reader.nextInt();

                sumhop2 = o4+o5+o6+o7+o8;
                angrythug = 3 + (int)(Math.random()*85); 
                    }else if(sumhop2<angrythug){
                        thugloop = false;
                        break;

                    }

                }

                System.out.println("Aha, the thug picked: " + angrythug + " -- you couldn't outdo the thug, could you? Well, it was a good run; time to do battle with the skeleton.");
                        Thread.sleep(3000);
                        s4="n";

            }

            } if(s4.equals("n")){
                   Thread.sleep(1000);
                   System.out.println("Now -- it is time to fight the skeleton");
                Thread.sleep(2000);
                System.out.println("Your survival depends on your mathematics skills.");
                              Thread.sleep(2700);
                                System.out.println("Type in your answers one-by-one.");
                                Thread.sleep(2500);
                                  System.out.println("By the way, Fetty Wap's song six-seven-nine is missing something.");
                                  Thread.sleep(3500);
                                System.out.println("(1) What is the highest power of 2 that divides 10! (factorial)");
                                Thread.sleep(4000);
                                System.out.println("(2) You write the numbers from 1... onwards like: 123456789(10)(11)..(643)..(707)..(984)... What is the number that starts on the 2013th digit of this sequence?" );
                                int a1 = reader.nextInt();
                                int a2 = reader.nextInt();
                                int suma = a1+a2;
                                if(suma==715){
                                    System.out.println("Wow, you're pretty damn smart; you beat the skeleton and all the odds. You might have won the game, all there is left is one question. READ CAREFULLY.");
                                    Thread.sleep(5000);
                                    System.out.print('\f');
                                    System.out.println("Read carefully: Write your answers AFTER ALL QUESTIONS APPEARED;");
                                    System.out.println("I hope you remembered everything; one-by-one, in order- write how many times you:");
                                    System.out.println("(1) Walked up the stairs (including loops, everything)");
                                    System.out.println("(2) How many times you beat the thug at hopscotch (including loops etc..)");
                                    int f1, f2;
                                    f1 = reader.nextInt();
                                    f2 = reader.nextInt();
                                    int sumf = f1+f2;
                                    if(sumf==counter+counter2){
                                        System.out.println("Congratulations, you have beaten the odds and won the game. Now, do something worthwhile =)");
                                        System.exit(0);

                                    }


                                }

            }




        }   if(i1 == 2){

          Thread.sleep(500);
            System.out.println("You go inside a dungeon, and meet a skeleton there; ");
            Thread.sleep(1000);
            System.out.println("You  talk to the skeleton; Press 'y' if you want to play thug hop-scotch, or 'n' if you want to fight.");
            s4=reader.next();
            if(s4.equals("y")){
                Thread.sleep(1000);
                System.out.println("Enter some 5 (after this) from 1 to maximum-17 (inclusive) individually. Repeats are allowed.");
                i4=reader.nextInt();
                i5=reader.nextInt();
                i6=reader.nextInt();
                i7=reader.nextInt();
                i8=reader.nextInt();
                int sumhop = i4 + i5 + i6 + i7 + i8;
                System.out.println("Through a complex algorithm your sequence of numbers read " + sumhop);
                Thread.sleep(3700);
                System.out.println("Fortunately (or unforunately) the thug you were playing hopscotch against was confident so he had this program generate him a random number.");
                Thread.sleep(2500);
                int randomhop = 3 + (int)(Math.random()*84); //thug hop scotch random.

                System.out.println("His random number generated was: " + randomhop);

                Thread.sleep(1000);
                if(sumhop < randomhop){

                System.out.println("Seriously? READ CAREFULLY - When asking the question, I told you: 'Enter 5 SUM-numbers-MAXIMUM'.");
                Thread.sleep(3000);
                System.out.println("You should have done 17*5  = 85 to outbeat the thug");
                Thread.sleep(3000);
                System.out.println("Anyway, time to do battle with the thug skeleton!");
                counter2=0;


            } else if(sumhop > randomhop){
                System.out.println("Woah, you beat the thug; but now the thug is angry and he won't rest until he beats you.");
                Thread.sleep(2000);
                thugloop = true;
                  System.out.println("Pick your numbers again");

                  o4=reader.nextInt();
                o5=reader.nextInt();
                o6=reader.nextInt();
                o7=reader.nextInt();
                o8=reader.nextInt();
                int sumhop2 = o4+o5+o6+o7+o8;
                  int angrythug = 3 + (int)(Math.random()*85); 

                while(thugloop == true){



                  if(sumhop2>angrythug){
                      counter2++;
                      Thread.sleep(1000);
                      System.out.println("The thug picked: " + angrythug + " .Woah, you are really good at this!");
                      Thread.sleep(1500);
                       System.out.println("But the thug is getting angrier. Pick again!");
                         o4=reader.nextInt();
                o5=reader.nextInt();
                o6=reader.nextInt();
                o7=reader.nextInt();
                o8=reader.nextInt();

                sumhop2 = o4+o5+o6+o7+o8;
                angrythug = 3 + (int)(Math.random()*85); 
                    }else if(sumhop2<angrythug){
                        thugloop = false;
                        break;

                    }

                }

                System.out.println("Aha, the thug picked: " + angrythug + " -- you couldn't outdo the thug, could you? Well, it was a good run; time to do battle with the skeleton.");
                        Thread.sleep(3000);
                        s4="n";

            }

            } if(s4.equals("n")){
                   Thread.sleep(1000);
                   System.out.println("Now -- it is time to fight the skeleton");
                Thread.sleep(2000);
                System.out.println("Your survival depends on your mathematics skills.");
                              Thread.sleep(2700);
                                System.out.println("Type in your answers one-by-one.");
                                Thread.sleep(2500);
                                  System.out.println("By the way, Fetty Wap's song six-seven-nine is missing something.");
                                  Thread.sleep(3500);
                                System.out.println("(1) What is the highest power of 2 that divides 10! (factorial)");
                                Thread.sleep(4000);
                                System.out.println("(2) You write the numbers from 1... onwards like: 123456789(10)(11)..(643)..(707)..(984)... What is the number that starts on the 2013th digit of this sequence?" );
                                int a1 = reader.nextInt();
                                int a2 = reader.nextInt();
                                int suma = a1+a2;
                                if(suma==715){
                                    System.out.println("Wow, you're pretty damn smart; you beat the skeleton and all the odds. You might have won the game, all there is left is one question. READ CAREFULLY.");
                                    Thread.sleep(5000);
                                    System.out.print('\f');
                                    System.out.println("Read carefully: Write your answers AFTER ALL QUESTIONS APPEARED;");
                                    System.out.println("I hope you remembered everything; one-by-one, in order- write how many times you:");
                                    System.out.println("(1) Walked up the stairs (including loops, everything)");
                                    System.out.println("(2) How many times you beat the thug at hopscotch (including loops etc..)");
                                    int f1, f2;
                                    f1 = reader.nextInt();
                                    f2 = reader.nextInt();
                                    int sumf = f1+f2;
                                    if(sumf==counter+counter2){
                                        System.out.println("Congratulations, you have beaten the odds and won the game. Now, do something worthwhile =)");
                                        System.exit(0);

                                    }


                                }

        }  if(i1 == 3){
            Thread.sleep(1);
            System.out.println("Oooooooooh... you picked the maze - good luck");
            Thread.sleep(2000);
            System.out.println("You stepped on a trap and fall in a dungeon. One way you see the light, the other, darkness. Press 'y' for light-way and 'd' for dark-way.");
            String dun = reader.next();
            if(dun.equals("y")){
                System.out.println("Good you saw the light, now you see a white board with a math question. Press 'y' to proceed or 'n' to go to the dark side.");
                String pro = reader.next();
                if(pro.equals("y")){
                    System.out.println("You have chosen to answer the math question.... smart choice.");
                    Thread.sleep(2000);
                    System.out.println("what is 2^2?");
                    int ans = reader.nextInt();
                   Thread.sleep(7700);
                   System.out.println("You really thought it would be that easy?");
                   Thread.sleep(1000);
                   System.out.println("You are given a 12th degree polynomial is the form: P(x) = 23x^(12) + ax^(11) +  ... + 8");
                   Thread.sleep(1500);
                   System.out.println("The roots are respectively: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12");
                   Thread.sleep(3000);
                   System.out.println("What is the absolute value of the coefficient 'a' in the poylnomial P(x)?");
                   int poly = reader.nextInt();

                   if(poly==161){
                       System.out.println("You have done what many others never could. Now do something worthwhile!");
                        System.exit(0);

                    }

                } else if(pro.equals("n")){
                    dun="n";
                }

            } if(dun.equals("n")){
                System.out.println("Okay, you chose the dark side - what is the first name of the 4th US President? (No caps)");
                String res = reader.next();
                if(res.equals("james")){
                    System.out.println("Nice. Suddenly, an earthquake appears and you fall down the dungeon.");
                    Thread.sleep(1500);
                    System.out.println("You are stuck with a skeleton who wants to play thug hopscotch really badly; you must play - get ready!");
                    Thread.sleep(4300);


            }



        }  if(i1 == 4){

            System.out.println("Huh - smart guy, you won the game.");
            System.exit(0);
        }

    }





     }
    }
     }
     }
i1
是输入
i1==1
i1==2
起作用,但
i1==3
并且,
i1==4
导致软件中断,问题是什么

以下是完整的代码:

/**
 * Write a description of class GameE02 here.
 * 
 * @Aakarsh
 * @1.0 (18 October 2015)
  */

 import java.util.*;


 //System.out.print('\f'); clear everything.


 public class GameE02
 {

 public static void main(String [] args) throws InterruptedException{

   Scanner reader = new Scanner(System.in);


   int i1, i2, i3, i4, i5, i6, i7, i8, i9;
   int o1, o2, o3, o4, o5, o6, o7, o8, o9;
   String s1, s2, s3, s4, s5, s6, s7, s8, s9;
   boolean loop = false;
   boolean thugloop = false; //thug hop scotch loop
   int counter = 1; //staircase counter
   int counter2 = 1; //thug hopscotch counter
   //somewhere, add in a never ending loop cycle (game over basically). Secret code required to end the game.


   System.out.println("Do you want to play a game? (y = yes, n = no)");

   s1 = reader.next();


   System.out.println("You walk into a room, there are 5 doors on the left one room on the right, you look at the room; do you wish to enter?");
   s2 = reader.next();


   //Begin the stairchase choice - Step 1 of the game.




   if(s2.equals("y")){

       Thread.sleep(1000);
       System.out.println("You have entered the room, you see a spiral staircase going up or chance to exit; you look at the staircase, do you wish to enter?");
       s3 = reader.next();
       Thread.sleep(1000);
       loop = true;

        System.out.println("You walk up the stairs, but you shockingly see yourself back in the same room, same position, climb again?");
       s3 = reader.next();  //begin the staircase loop

       while(loop==true){



       if(s3.equals("y")){
            System.out.println("You walk up the stairs, but you shockingly see yourself back in the same room, same position, climb again?");
       s3 = reader.next();
      counter++;

        }else if(s3.equals("n")){

            System.out.println("You have chosen not to climb the staircase.");

            loop=false;
            break;
        }


    }  //loop ends here.


    Thread.sleep(1000);

    System.out.println("You are frightened and you walk back and see six doors, pick one (1, 2, 3, 4, 5, 6)");
    //pun - pick one
    s5=reader.next();

    if(s5.equals("1")){

        System.out.println("Good, you understood the pun; you may still have a chance at surviving.");
        Thread.sleep(1000);


        //add in the rest of the code here.


    }else{

        System.out.println("Damn, you really suck at reading - what are you, an AP Computer Science student? I said: 'six doors.. pick ONE...");
        Thread.sleep(3950);
        System.out.println("Since you lost that, I need to put you in the maze, sorry!");
    }


    }  if(s2.equals("n")){
        counter=0;
       Thread.sleep(1000); 

        System.out.println("You see four doors, which one do you pick? (1, 2, 3, 4)");
        i1 = reader.nextInt(); //door choice number. 

        if(i1 == 1){
            Thread.sleep(500);
            System.out.println("You go inside a dungeon, and meet a skeleton there; ");
            Thread.sleep(1000);
            System.out.println("You  talk to the skeleton; Press 'y' if you want to play thug hop-scotch, or 'n' if you want to fight.");
            s4=reader.next();
            if(s4.equals("y")){
                Thread.sleep(1000);
                System.out.println("Enter some 5 (after this) from 1 to maximum-17 (inclusive) individually. Repeats are allowed.");
                i4=reader.nextInt();
                i5=reader.nextInt();
                i6=reader.nextInt();
                i7=reader.nextInt();
                i8=reader.nextInt();
                int sumhop = i4 + i5 + i6 + i7 + i8;
                System.out.println("Through a complex algorithm your sequence of numbers read " + sumhop);
                Thread.sleep(3700);
                System.out.println("Fortunately (or unforunately) the thug you were playing hopscotch against was confident so he had this program generate him a random number.");
                Thread.sleep(2500);
                int randomhop = 3 + (int)(Math.random()*84); //thug hop scotch random.

                System.out.println("His random number generated was: " + randomhop);

                Thread.sleep(1000);
                if(sumhop < randomhop){

                System.out.println("Seriously? READ CAREFULLY - When asking the question, I told you: 'Enter 5 SUM-numbers-MAXIMUM'.");
                Thread.sleep(3000);
                System.out.println("You should have done 17*5  = 85 to outbeat the thug");
                Thread.sleep(3000);
                System.out.println("Anyway, time to do battle with the thug skeleton!");
                counter2=0;


            } else if(sumhop > randomhop){
                System.out.println("Woah, you beat the thug; but now the thug is angry and he won't rest until he beats you.");
                Thread.sleep(2000);
                thugloop = true;
                  System.out.println("Pick your numbers again");

                  o4=reader.nextInt();
                o5=reader.nextInt();
                o6=reader.nextInt();
                o7=reader.nextInt();
                o8=reader.nextInt();
                int sumhop2 = o4+o5+o6+o7+o8;
                  int angrythug = 3 + (int)(Math.random()*85); 

                while(thugloop == true){



                  if(sumhop2>angrythug){
                      counter2++;
                      Thread.sleep(1000);
                      System.out.println("The thug picked: " + angrythug + " .Woah, you are really good at this!");
                      Thread.sleep(1500);
                       System.out.println("But the thug is getting angrier. Pick again!");
                         o4=reader.nextInt();
                o5=reader.nextInt();
                o6=reader.nextInt();
                o7=reader.nextInt();
                o8=reader.nextInt();

                sumhop2 = o4+o5+o6+o7+o8;
                angrythug = 3 + (int)(Math.random()*85); 
                    }else if(sumhop2<angrythug){
                        thugloop = false;
                        break;

                    }

                }

                System.out.println("Aha, the thug picked: " + angrythug + " -- you couldn't outdo the thug, could you? Well, it was a good run; time to do battle with the skeleton.");
                        Thread.sleep(3000);
                        s4="n";

            }

            } if(s4.equals("n")){
                   Thread.sleep(1000);
                   System.out.println("Now -- it is time to fight the skeleton");
                Thread.sleep(2000);
                System.out.println("Your survival depends on your mathematics skills.");
                              Thread.sleep(2700);
                                System.out.println("Type in your answers one-by-one.");
                                Thread.sleep(2500);
                                  System.out.println("By the way, Fetty Wap's song six-seven-nine is missing something.");
                                  Thread.sleep(3500);
                                System.out.println("(1) What is the highest power of 2 that divides 10! (factorial)");
                                Thread.sleep(4000);
                                System.out.println("(2) You write the numbers from 1... onwards like: 123456789(10)(11)..(643)..(707)..(984)... What is the number that starts on the 2013th digit of this sequence?" );
                                int a1 = reader.nextInt();
                                int a2 = reader.nextInt();
                                int suma = a1+a2;
                                if(suma==715){
                                    System.out.println("Wow, you're pretty damn smart; you beat the skeleton and all the odds. You might have won the game, all there is left is one question. READ CAREFULLY.");
                                    Thread.sleep(5000);
                                    System.out.print('\f');
                                    System.out.println("Read carefully: Write your answers AFTER ALL QUESTIONS APPEARED;");
                                    System.out.println("I hope you remembered everything; one-by-one, in order- write how many times you:");
                                    System.out.println("(1) Walked up the stairs (including loops, everything)");
                                    System.out.println("(2) How many times you beat the thug at hopscotch (including loops etc..)");
                                    int f1, f2;
                                    f1 = reader.nextInt();
                                    f2 = reader.nextInt();
                                    int sumf = f1+f2;
                                    if(sumf==counter+counter2){
                                        System.out.println("Congratulations, you have beaten the odds and won the game. Now, do something worthwhile =)");
                                        System.exit(0);

                                    }


                                }

            }




        }   if(i1 == 2){

          Thread.sleep(500);
            System.out.println("You go inside a dungeon, and meet a skeleton there; ");
            Thread.sleep(1000);
            System.out.println("You  talk to the skeleton; Press 'y' if you want to play thug hop-scotch, or 'n' if you want to fight.");
            s4=reader.next();
            if(s4.equals("y")){
                Thread.sleep(1000);
                System.out.println("Enter some 5 (after this) from 1 to maximum-17 (inclusive) individually. Repeats are allowed.");
                i4=reader.nextInt();
                i5=reader.nextInt();
                i6=reader.nextInt();
                i7=reader.nextInt();
                i8=reader.nextInt();
                int sumhop = i4 + i5 + i6 + i7 + i8;
                System.out.println("Through a complex algorithm your sequence of numbers read " + sumhop);
                Thread.sleep(3700);
                System.out.println("Fortunately (or unforunately) the thug you were playing hopscotch against was confident so he had this program generate him a random number.");
                Thread.sleep(2500);
                int randomhop = 3 + (int)(Math.random()*84); //thug hop scotch random.

                System.out.println("His random number generated was: " + randomhop);

                Thread.sleep(1000);
                if(sumhop < randomhop){

                System.out.println("Seriously? READ CAREFULLY - When asking the question, I told you: 'Enter 5 SUM-numbers-MAXIMUM'.");
                Thread.sleep(3000);
                System.out.println("You should have done 17*5  = 85 to outbeat the thug");
                Thread.sleep(3000);
                System.out.println("Anyway, time to do battle with the thug skeleton!");
                counter2=0;


            } else if(sumhop > randomhop){
                System.out.println("Woah, you beat the thug; but now the thug is angry and he won't rest until he beats you.");
                Thread.sleep(2000);
                thugloop = true;
                  System.out.println("Pick your numbers again");

                  o4=reader.nextInt();
                o5=reader.nextInt();
                o6=reader.nextInt();
                o7=reader.nextInt();
                o8=reader.nextInt();
                int sumhop2 = o4+o5+o6+o7+o8;
                  int angrythug = 3 + (int)(Math.random()*85); 

                while(thugloop == true){



                  if(sumhop2>angrythug){
                      counter2++;
                      Thread.sleep(1000);
                      System.out.println("The thug picked: " + angrythug + " .Woah, you are really good at this!");
                      Thread.sleep(1500);
                       System.out.println("But the thug is getting angrier. Pick again!");
                         o4=reader.nextInt();
                o5=reader.nextInt();
                o6=reader.nextInt();
                o7=reader.nextInt();
                o8=reader.nextInt();

                sumhop2 = o4+o5+o6+o7+o8;
                angrythug = 3 + (int)(Math.random()*85); 
                    }else if(sumhop2<angrythug){
                        thugloop = false;
                        break;

                    }

                }

                System.out.println("Aha, the thug picked: " + angrythug + " -- you couldn't outdo the thug, could you? Well, it was a good run; time to do battle with the skeleton.");
                        Thread.sleep(3000);
                        s4="n";

            }

            } if(s4.equals("n")){
                   Thread.sleep(1000);
                   System.out.println("Now -- it is time to fight the skeleton");
                Thread.sleep(2000);
                System.out.println("Your survival depends on your mathematics skills.");
                              Thread.sleep(2700);
                                System.out.println("Type in your answers one-by-one.");
                                Thread.sleep(2500);
                                  System.out.println("By the way, Fetty Wap's song six-seven-nine is missing something.");
                                  Thread.sleep(3500);
                                System.out.println("(1) What is the highest power of 2 that divides 10! (factorial)");
                                Thread.sleep(4000);
                                System.out.println("(2) You write the numbers from 1... onwards like: 123456789(10)(11)..(643)..(707)..(984)... What is the number that starts on the 2013th digit of this sequence?" );
                                int a1 = reader.nextInt();
                                int a2 = reader.nextInt();
                                int suma = a1+a2;
                                if(suma==715){
                                    System.out.println("Wow, you're pretty damn smart; you beat the skeleton and all the odds. You might have won the game, all there is left is one question. READ CAREFULLY.");
                                    Thread.sleep(5000);
                                    System.out.print('\f');
                                    System.out.println("Read carefully: Write your answers AFTER ALL QUESTIONS APPEARED;");
                                    System.out.println("I hope you remembered everything; one-by-one, in order- write how many times you:");
                                    System.out.println("(1) Walked up the stairs (including loops, everything)");
                                    System.out.println("(2) How many times you beat the thug at hopscotch (including loops etc..)");
                                    int f1, f2;
                                    f1 = reader.nextInt();
                                    f2 = reader.nextInt();
                                    int sumf = f1+f2;
                                    if(sumf==counter+counter2){
                                        System.out.println("Congratulations, you have beaten the odds and won the game. Now, do something worthwhile =)");
                                        System.exit(0);

                                    }


                                }

        }  if(i1 == 3){
            Thread.sleep(1);
            System.out.println("Oooooooooh... you picked the maze - good luck");
            Thread.sleep(2000);
            System.out.println("You stepped on a trap and fall in a dungeon. One way you see the light, the other, darkness. Press 'y' for light-way and 'd' for dark-way.");
            String dun = reader.next();
            if(dun.equals("y")){
                System.out.println("Good you saw the light, now you see a white board with a math question. Press 'y' to proceed or 'n' to go to the dark side.");
                String pro = reader.next();
                if(pro.equals("y")){
                    System.out.println("You have chosen to answer the math question.... smart choice.");
                    Thread.sleep(2000);
                    System.out.println("what is 2^2?");
                    int ans = reader.nextInt();
                   Thread.sleep(7700);
                   System.out.println("You really thought it would be that easy?");
                   Thread.sleep(1000);
                   System.out.println("You are given a 12th degree polynomial is the form: P(x) = 23x^(12) + ax^(11) +  ... + 8");
                   Thread.sleep(1500);
                   System.out.println("The roots are respectively: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12");
                   Thread.sleep(3000);
                   System.out.println("What is the absolute value of the coefficient 'a' in the poylnomial P(x)?");
                   int poly = reader.nextInt();

                   if(poly==161){
                       System.out.println("You have done what many others never could. Now do something worthwhile!");
                        System.exit(0);

                    }

                } else if(pro.equals("n")){
                    dun="n";
                }

            } if(dun.equals("n")){
                System.out.println("Okay, you chose the dark side - what is the first name of the 4th US President? (No caps)");
                String res = reader.next();
                if(res.equals("james")){
                    System.out.println("Nice. Suddenly, an earthquake appears and you fall down the dungeon.");
                    Thread.sleep(1500);
                    System.out.println("You are stuck with a skeleton who wants to play thug hopscotch really badly; you must play - get ready!");
                    Thread.sleep(4300);


            }



        }  if(i1 == 4){

            System.out.println("Huh - smart guy, you won the game.");
            System.exit(0);
        }

    }





     }
    }
     }
     }
/**
*在这里写下GameE02类的描述。
* 
*@Aakarsh
*@1.0(2015年10月18日)
*/
导入java.util.*;
//系统输出打印('\f');清除一切。
公共类游戏02
{
公共静态void main(字符串[]args)引发InterruptedException{
扫描仪阅读器=新扫描仪(System.in);
inti1,i2,i3,i4,i5,i6,i7,i8,i9;
INTO1,o2,o3,o4,o5,o6,o7,o8,o9;
串s1、s2、s3、s4、s5、s6、s7、s8、s9;
布尔循环=假;
布尔thugloop=false;//恶棍跳苏格兰循环
int计数器=1;//楼梯计数器
int counter 2=1;//暴徒跳房子计数器
//在某个地方,加入一个永无止境的循环(游戏基本结束)。结束游戏所需的密码。
System.out.println(“您想玩游戏吗?(y=yes,n=no)”;
s1=reader.next();
System.out.println(“你走进一个房间,左边有5扇门,右边有一个房间,你看着这个房间;你想进去吗?”);
s2=reader.next();
//开始StairCase选择-游戏的第一步。
如果(s2等于(“y”)){
睡眠(1000);
System.out.println(“你已经进入房间,你看到一个螺旋楼梯向上或有机会退出;你看着楼梯,你想进去吗?”);
s3=reader.next();
睡眠(1000);
循环=真;
println(“你走上楼梯,却惊讶地发现自己回到了同一个房间,同一个位置,又爬了起来?”);
s3=reader.next();//开始楼梯循环
while(循环==true){
如果(s3等于(“y”)){
println(“你走上楼梯,却惊讶地发现自己回到了同一个房间,同一个位置,又爬了起来?”);
s3=reader.next();
计数器++;
}else如果(s3等于(“n”)){
System.out.println(“您选择了不爬楼梯。”);
循环=假;
打破
}
}//循环到此结束。
睡眠(1000);
println(“你害怕了,走回去看到六扇门,选一扇门(1,2,3,4,5,6)”;
//双关语-挑一个
s5=读卡器。下一步();
如果(s5.等于(“1”)){
很好,你理解这个双关语;你可能还有机会活下来;
睡眠(1000);
//在这里添加其余的代码。
}否则{
“该死,你真的很烂,你是AP计算机科学专业的学生吗?我说:‘六扇门……挑一扇门……);
睡眠(3950);
因为你把它弄丢了,我要把你放进迷宫里,对不起;
}
}如果(s2等于(“n”)){
计数器=0;
睡眠(1000);
println(“您看到四个门,您选择哪一个?(1、2、3、4)”;
i1=reader.nextInt();//门选择编号。
如果(i1==1){
睡眠(500);
println(“你进入一个地牢,在那里遇到一个骷髅;”;
睡眠(1000);
println(“你和骷髅说话;如果你想玩暴徒跳苏格兰,按“y”,如果你想打架,按“n”);
s4=读卡器.next();
如果(s4等于(“y”)){
睡眠(1000);
System.out.println(“分别输入从1到最多17(含)的5个字符(在此之后)。允许重复。”);
i4=reader.nextInt();
i5=reader.nextInt();
i6=reader.nextInt();
i7=reader.nextInt();
i8=reader.nextInt();
int sumhop=i4+i5+i6+i7+i8;
System.out.println(“通过复杂算法,您的数字序列读取”+sumhop);
睡眠(3700);
println(“幸运的(或不幸的)是,你玩跳房子的那个暴徒很自信,所以他让这个程序给他生成了一个随机数。”);
睡眠(2500);
int randomhop=3+(int)(Math.random()*84);//暴徒跳跃苏格兰随机。
System.out.println(“他生成的随机数是:“+randomhop”);
睡眠(1000);
if(sumhoprandomhop){
系统输出println(“哇,你打了那个暴徒;但现在暴徒很生气,他不会休息,直到他打了你。”);
《睡眠》(2000年);
thugloop=true;
System.out.println(“再次选择您的号码”);
o4=reader.nextInt();
o5=reader.nextInt();
o6=reader.nextInt();
o7=reader.nextInt();
o8=reader.nextInt();
int sumhop2=o4+o5+o6+o7+o8;
int angrythug=3+(int)(Math.random()*85);
while(thugloop==true){
如果(sumhop2>愤怒暴徒){
计数器2++;
睡眠(1000);
System.out.println(“暴徒选择:“+angrythug+”。哇,你真的很擅长这个!”;