Hi:
I've been trying to create a class that would keep track of the
number of players. My thought was to create a game on an applet and
then whenever an instance of the applet was loaded by a client a class
named NumberOfPlayers would keep track of the number of players. I
thought all I would need to do was declare a static variable like:
private static int Players = 0;

but this doesn't seem to work. The entire class looks like this:

public class NumberOfPlayers
{
private static int Players = 0;

public int getNumberOfPlayersAsInt()
{
return Players;
}

public String getNumberOfPlayersAsString()
{
return String.valueOf(Players);
}

public void addNewPlayer(int newPlayer)
{
Players = Players + newPlayer;
}

public void removePayer(int retiredPlayer)
{
Players = Players - retiredPlayer;
}
}

When an instance of the game applet opens I make a call to the
constructor like:
NumberOfPlayers nPlayers = new NumberOfPlayers(); //declaration

public game(){nPlayers.addNewPlayer(1);}//constructor

When I open two instances of the game applet the return value of
nPlayers.getNumberOfPlayersAsString() is always one [1] not two [2] as
expected.

How can I change my approach so as to make this work?

Thanks,

Alan