Struggling to word this one but I have a list of players in a league. A league has a list of rounds, which has a list of games. I need to create games using two players from the list of players in the league
How can i ensure that when I create a game it does not use a player that has already been selected, as they are selected randomly from the list.
If i remove them from the list once they are selected then they are removed from the league, which I do not want. If I copy the list of players (and remove from that) then the ones being used to create the games are not the original player objects
public Player(int Id, String eMail, String forename, String lastname,League league) {
this.msaId = Id;
this.eMail = eMail;
this.firstName = forename;
this.lastName = lastname;
this.league = league;
}
public League(int Id, String leagueName, List<Player> players, List<Round> rounds, int numberOfPlayers, Tournament t) {
this.Id = Id;
this.name = leagueName;
this.players = players;
this.rounds = rounds;
this.numberOfPlayers = numberOfPlayers;
this.tournament = t;
}
public Round(int Id, int numberOfPlayers, int roundNumber, League league) {
this.Id = Id;
this.roundType = roundType;
this.roundNumber = roundNumber;
this.league = league;
this.currentRound = false;
this.roundStarted = false;
}
public Game(int Id, int gameNumber, int roundId, Player playerOne, Player playerTwo, int tableNumber, Round r) {
this.Id = Id;
this.gameNumber = gameNumber;
this.roundId = roundId;
this.playerOne = playerOne;
this.playerTwo = playerTwo;
this.tableNumber = tableNumber;
this.playerOneScore = 0;
this.playerTwoScore = 0;
this.round = r;
}
Playerclass, isSelected as abooleanand when you use the random selection and the player.isSelected is true, pick anotherPlayer.