I'm trying to create a method 'GetPlayers' that returns an array of Class 'Player' inside the Class itself - Good idea or bad idea?
If good, how would I use the method to create an instance of the array?
e.g.
Player players = new Player.GetPlayers();
(yes it's still early days for me :rolleyes
Many thanks
Paul.
public class Player {
private int gold = 30;
private int warriors = 10;
private int food = 25;
private int[] boughtItems = null;
private int[] foundItems = null;
private int kingdom = 0;
private int moves = 0;
private int lastLocation = 0;
private boolean cursed = false;
public Player[] GetPlayers(){
Player players[];
players = new Player[6]; //CurrPlayer, 4xPlayers + Dragon
for (int i=0; i<players.length; ++i)
players[i] = new Player();
players[5].gold = 0; //Dragon!!!
players[5].warriors = 0; //Dragon!!!
return players;
}
}