For our project, we have made a Players class. The idea behind this was to make an instance of this class for each player. This class contains some variables that can be retrieved with different functions.
The question is how do we call this class multiple (variable) times in a loop, but each time with a different name and different input variables. We want the number of players to be variable and different variables for each player.
Here is the class declaration from the .h file:
class Players {
private:
String _UID;
boolean _Thief;
String _color;
public:
Players(String UID, String color, boolean Thief);
String getUID();
boolean isThief();
};
And I want to call this class in a function that would look something like this:
for (int i = 0; i <= AMOUNT OF PLAYERS; i++) {
//Some functions to read the right input for this player
Read UID ();
Get color ();
Get thiefstate ();
Players player1 ("UID in string here", "color here", True of False here) //Player1 should become player 2 the second time etc
}
How can we change the name of the class instance each time? And whould this approach work or is there a better way to do this?
Thanks in advance