title: Java Method not working constantly
body: <p>I have a text based game that I am making. It is a RPG style where the user is given options linked to numbers and they have to choose a number. Now my problem is that when running the program. A certain method, Decision(), only works certain times. The method is in a superClass while it is being called in the subclass. in the subclass, It works the first time, but not necessarily the second. Also, when I copy the decision method from the superclass into the subclass its starts working, but the next time it is called, it stops. Here is what I've tried and the results. I've included the decision method and where it is being called.</p>
  
  <p>Decision Method:</p>
  
  <pre><code>public int decision(String question, int length, String[] choices){
      int[] numbers = new int[length];
      int iterator = 1;
      for(int i = 0; i &lt; length; i++){
          numbers[i] = iterator;
          iterator++;
      }
      boolean done = false;
      while(!done){
          //print("Test");
          print("");
          print(question);
          String options = "";
          for(int i = 0; i &lt; numbers.length; i++){
              options = (options + numbers[i] + " - " + choices[i] + "  ");
          }
          print(options);
          boolean univSet = true;
          int entry = 1;
          while(univSet){
              if(univInt != 0){
                  univSet = false;
                  entry = univInt;
                  univInt = 0;
                  //print("testing");
              }
          }
          if(entry == 23){
              help();
          }else{
              for(int i = 0; i &lt; numbers.length; i++){
                  if(entry == numbers[i]){
                      done = true;
                      univInt = 0;
                      return entry;
                  }
              }
              print("Invalid Number, Try again");
              print("");
              univInt = 0;
          }
      }
      return (Integer) null;
  }
  </code></pre>
  
  <p>Chapter1 Class (Where it's being called:</p>
  
  <pre><code>public class Chapter1 extends Story implements Serializable {
  
  
  Player player;
  public Chapter1(Player player){
      this.player = player;
  }
  public void engage() {
      // TODO Auto-generated method stub
      player.chapter = 1;
      save(player.name);
      sPrint("Welcome to Chapter 1");
      print("You wake up in a lighted room with white walls.\nA fresh breeze is coming through the window yet the air smells rotten.");
      print("You jolt up suddenly. You don't remember anything about how you got here. You've even forgotten who you are.");
      print("You look down at your white shirt, there is a streak of blood across the top.\nYou are wearing a nametag that says: " + player.name + ".");
      print("You're sitting in a chair but there are no restraints. You decide to get up and look around");
      cur = decision("What do you do?", 2, new String[]{"Try the door", "Look out the window"});
      print(cur + "");
      if(cur == 1){
          print("You walk over to the door and try and open it, it is unlocked.\nYou walk through and are welcomed by a cold and poorly lit hallway");
      }else{
          print("You walk to the window and look outside. You see a huge barren field. You can make out a humanoid like structure.\nYou call out yet the figure doesn't move.");
          print("You decide to try the door. It's unlocked so you walk through into a cold dimly lit hallway.");
      }
      print("You see a dull knife on the floor as well as a door on the end of the hallway");
      cur = decision("What do you do?", 2, new String[]{"Go to the door", "Take the knife"});
      if(cur == 2){
          print("You pick up the knife.");
          addWeapon("Kitchen Knife", player);
  
      }else{
          print("You walk down the hallway to the door when suddenly the door opens and out comes a zombie.\nIt Lunges for your shoulder. You are caught by surprise and it bites into your skin and you are infected");
          gameOver();
      }
      print("You continue to walk down the hall when suddenly a hideous creature lunges out from the door.\nYou jump back and prepare yourself for a battle.");
      battle("Zombie", 5, 2, player);
  
      sPrint("I see that you have succeeded in your first encounter with the undead.\nI congratulate you but you have a long way to go. Remember, I am your only way to learning about your past. \nNow, make your way down to the bottom of the tower. I will help you where I see fit along the way.");
      print("You look around and see that the lights have brightened up. The zombie has been mutilated by your Kitchen Knife. \nYou don't know where the voice came from but you are scared. Behind the zombie's original hiding spot you see a staircase.\nYou follow it down, onto what seems to be..the 11th floor.");
      print("");
      print("Please input 'complete' to continue");
      pause();
      sPrint("Chapter 1 complete");
  
  }
  </code></pre>
  
  <p>Now in this class, engage() is being called to run this chapter. And decision is being called where you see it, as well as in the battle() method(the battle method loops a couple times and decision() is called every loop. </p>
  
  <p>Originally, both Decision and battle are in the superclass, but not in the sub class. This results in the first decision method in the class to be called, but not the second. In the second, it stops at the loop checking the value of univInt.</p>
  
  <p>When I put the decision method into the sub class, It passes the first two but it fails to get past the first one in the battle method for the same reason.</p>
  
  <p>When I put both the decision and battle method into the sub class, it has the same result as just putting decision. </p>
  
  <p>Finally if I put battle in the sub class but not decision it only passes the first two again. </p>
  
  <p>In the project I have one variable named cur that holds the integer value of whatever decision returns. I reuse it for every decision. I don't know if that has anything to do with it. This really doesn't make sense to me how whether the methods are in the same class, or inherited would matter at all if they are the same method.</p>
  
  <p>I am ready to clarify anything and I hope someone is able to understand what is going wrong.</p>
  
  <p>EDIT:</p>
  
  <p>univInt is being set to another number other than 0 outside of decision. thats why it works some times. It is a swing class and a method in a superclass sets univInt to whatever is in a TextField when a button is pressed so with that while loop I try to constantly check to see univInt has been changed from 0</p>