92.1k views
3 votes
We have constructed a Player Class for you. Add the following: public static variable: int totalPlayers Static variable should be an int. The value should be incremented whenever a new Player is constructed. public static variable: int maxPlayers Static variable should be an int. Set its value to 10. public static method: gameFull() The gameFull() static method should return a boolean of whether the total players is greater than or equal to the maxPlayers static variable.

User Plynx
by
5.2k points

1 Answer

2 votes

Answer:

public class Player {

public static int totalPlayers = 0;

public static int maxPlayers = 10;

public static boolean gameFull() {

return totalPlayers >= maxPlayers;

}

public Player() { // Player class constructor

totalPlayers++;

}

}

Step-by-step explanation:

The Java program defines the class Player which has two public class variables and a public method. The class constructor increases the totalPlayer variable by one for every player object created.

User Corgrath
by
5.5k points