posted 4 years ago
I am used to having variable names such as player1, player2, etc..., but how do I do this if I don't know the number of players? (It's determined via user input.) My sort-of solution was to have the user input the number of players and then to create an array of that length. The user then inputs the name of the n players and they become elements in the array via a loop executed n-times. My problem now is manipulating the elements. For example, if I want to give each player an amount of money that changes throughout the game, I don't really have the players as objects to manipulate. Can I use dot-operators on player, player, etc...?
Author and ninkuma