title: Confused on a class method that decides current Player
body: <p>I am currently in the process of doing an assignment on the game pick up sticks where the code prompts user to enter number of sticks from the game then player 1 and player 3 choose to pick between (1-3) sticks out of the bundles and whoever picks the last stick up wins the game. Im currently stuck on what do to within my getWinner() and my pickUpSticks() method. My idea was to try to have player 1 be even numbers and player 2 to be odd numbers so it would be easy to switch between the two by incrementing current player by 1 and using if statements to see if the were % 2 to decide what player's turn it is. The problem I'm having is that the code isn't working right and instead of having odds or evens determine if it's player 1 or 2 it just increments the players so it goes 0,1,2,3,4,5... My second problem I'm having is I'm not sure where to put the statement numOfSticks &lt; 0, the current place I have it now it allows the numOfSticks to become negative but once you try to enter in a new value it throws the exception, I want it to throw the exception before it evens allows it to become negative. Below I have posted the code, any help would be much appreciated. </p>
  
  <pre><code>import java.util.Scanner;
  
  /**
   * Plays a game of Sticks over and over until the players wish to quit.
   * 
   *
   */
  public class SticksGameApp 
  {
  
      int intialNumOfSticks;
      int numOfSticks;
      int currentPlayer = 0; 
  
  
     public SticksGameApp () {
           intialNumOfSticks = 20;    
           numOfSticks = 20;  
     }
  
     public SticksGameApp(int startSticks) {
           intialNumOfSticks = startSticks;
           numOfSticks = startSticks;
     }
  
     public int getNumOfSticks() {
           return numOfSticks;
  
     }
  
     public int getCurrentPlayer() {
           return currentPlayer;
     }
  
     public String getPile() {
           String pile = "";
  
           for(int i=0;i&lt;numOfSticks;i++){
                 String c = "|";
                 pile += c;
           }
           return pile;   
    }
  
     public boolean isOver() {
         if (numOfSticks == 0) return true;
         return false;
     }
  
     public int getWinner() {
     // player 1 is even, player 2 is odd
     int player1 = 1;
     int player2 = 2;
      if (currentPlayer  % 2 == 0) {
          return player1;
      }
      else if (currentPlayer % 2 == 1) {
          return player2;
      }
      else {
           return 0;
      }
  
  
     }
  
     public void reset() {
      currentPlayer = 0;
      numOfSticks = intialNumOfSticks;
  
     }
  
     public void pickUpSticks(int someInt)throws InvalidOptionException {
      if (someInt &lt; 1 || someInt &gt; 3 || numOfSticks &lt; 0)throw new InvalidOptionException();
          currentPlayer++;
          numOfSticks = numOfSticks - someInt;
  
  
     }
  
     /**
       * Plays the game of Sticks over and over until the players quit.
       * 
       * @param args not used.
       */
      public static void main(String[] args)
      {       
          int numSticks;
        //Initialize a Scanner object to read from the console input stream.
          Scanner consuleInput = new Scanner(System.in);
  
          //Ask the user for the number sticks to play with.
          System.out.println("It's time for an exciting game of Sticks!");
          System.out.println("How many sticks would you like to start with?");
          int intialNumOfSticks = consuleInput.nextInt();
  
          //Create a sticks game with the inputed number of sticks.
          SticksGameApp myGame = new SticksGameApp(intialNumOfSticks);
  
          //Keep playing games until the players want to quit.
          String playAgain = "Y";
          while (playAgain.toUpperCase().startsWith("Y"))
          {
              //Start with a fresh game.
              myGame.reset();
  
              //Keep playing until the game is over.
              while (!myGame.isOver())
              {
                  //Get the player's selection for the number of sticks to pick up.
                  System.out.println("\n\nPlayer " + myGame.getCurrentPlayer() + " there are " + myGame.getNumOfSticks() + " stick(s) left.");
                  System.out.println(myGame.getPile());
                  System.out.print("How many do you want to take (1-3): ");
                  numSticks = consuleInput.nextInt();
  
                  //Try picking up that many sticks.  If there is an exception, have the player reenter.
                  try
                  {
                      myGame.pickUpSticks(numSticks);
                  }
                  catch(InvalidOptionException e)
                  {
                      System.out.println("That is an invalid number of sticks!!! Try again.");
                  }
              }
  
              //Once the game is over, display who won.
              System.out.println("Player " + myGame.getWinner() + " wins!");
  
              //As the user to play again.
              System.out.println("\n\nThat was exciting, would you like to play again?");
              playAgain = consuleInput.next();
          }
  
          //Close the scanner object.
          consuleInput.close();
  
      }
  
  
  
  
  }
  
  
  Player 0 there are 5 stick(s) left.
  |||||
  How many do you want to take (1-3): 2
  
  
  Player 1 there are 3 stick(s) left.
  |||
  How many do you want to take (1-3): 1
  
  
  Player 2 there are 2 stick(s) left.
  ||
  How many do you want to take (1-3): 3
  
  
  Player 3 there are -1 stick(s) left.
  
  How many do you want to take (1-3): 2
  That is an invalid number of sticks!!! Try again.
  
  
  Player 3 there are -1 stick(s) left.
  
  How many do you want to take (1-3): 1
  That is an invalid number of sticks!!! Try again.
  
  
  Player 3 there are -1 stick(s) left.
  
  How many do you want to take (1-3): 3
  That is an invalid number of sticks!!! Try again.
  </code></pre>