Nim game - specify winner
<pre><code>import java.util.Scanner;
/**
 *@author Andy 
 *@verison 21.11.2012
 */
public class NimGame
{
public static void main (String[] args)
{
    System.out.println ("**********      Hello Welcome to the game Nim           *********");
    System.out.println ("               The game is relatively simple....        ");
    System.out.println ("               This is a game for two players.          "); 
    System.out.println ("            There is a heap containing 10 to 20 stones.");
    System.out.println ("           Players take turns to remove 1-4 stones     "); 
    System.out.println ("           The player who removes the last stone wins. ");
    System.out.println ("******************************************************************");

    Scanner scan = new Scanner (System.in);
    int heapSize = 15;
    int stones = 0;
    boolean nextInteger = false;
    boolean lessThanFour = false;
    String player1 = "Player 1";
    String player2 = "Player 2";
    String player = player1;

    System.out.println ("The number of stones currently in the heap is :- " + heapSize);
    System.out.println();

    while (heapSize &gt; 0)
    {

        nextInteger = false;
        lessThanFour = false;
        System.out.println (player + ":" + "how many stones will you take from the heap?");
        System.out.println();
        while (nextInteger == false &amp;&amp; lessThanFour == false)
        {

            if (scan.hasNextInt())
            {
                nextInteger = true;
                stones = scan.nextInt();

                if (stones &lt;=4 &amp;&amp; stones &gt;0)
                {
                    System.out.println();
                    System.out.println ("You picked " + stones);
                    heapSize = (heapSize - stones);
                    if (heapSize &gt;= 0)
                    {
                    System.out.println();
                    System.out.println ("There are " + heapSize + "stones left");  
                    System.out.println();
                    lessThanFour = true;
                    System.out.println();
                    if (player.equals(player1))
                    {
                        player = player2;
                    }
                    else

                    {
                        player = player1;
                    }



                }

                else 

                {
                    System.out.println ("Bad input, please try again");
                    nextInteger = false;
                    scan.nextLine();
                }
            }

            else 

            {
                System.out.println ("Bad input, please try again");
                scan.nextLine();
            }


        }
    }
}
}
}
</code></pre>

<p>I dunno how to implement a way to specify player 1 or player 2 being the winner once the sizeheap (number of stones left) reaches 0. Any help would be appreciated. Also when the sizeheap reaches a negative number, it will display 'bad input' but then any other number inserted after that also displays 'bad input.'</p>

<p>Thanks!</p>
