Say I have a Player class such as:
public class Player {
String name;
int chips;
int betVal;
}
Is the following code correct for creating the array of the players?
public static void main(String[] args) {
int playerCount;
int startingChip;
out.print("How many players? ");
playerCount = myScanner.nextInt();
Player[] aPlayer = new Player[playerCount + 1];
for (int i = 0; i < playerCount + 1; i++){
aPlayer[i] = new Player();
}
out.print("Enter starting chip amount: ");
startingChip = myScanner.nextInt();
}
If so, how would I assign the name, chip amount and the betVal to each player? How would I access and alter them later on in the code?
EDIT: Will it be easier leaving the Player as an object or an array (name,chips,betVal) for accessing it later on?