HELP. TYING TO MAKE SENSE OF A SCHEDULE
Hi im creating a following tournement schedule and the following code is used to generate fizxtures. However i am unsure as to how this happens and what each line actually does. I have commented each line could someone please advise if this is correct and when i try to create the matchups, how does this whole procedure work. For example, when it gets to i=3 and j=2 when 4 teams are participating, then the fixture gets generated 2 vs 5th team which cannot happen. i do not understand how this accompanies it. Thank you ever so much
bye at -1 means team has no bye
publicvoid League()
{
int TotalParticipants= List.size(), NoOfGames = TotalParticipants*(TotalParticipants-1)/2, tmp;
bye = -1;
game =newint[NoOfGames][3];
Team tmpTeam;//tmpteam stores team
for(int i = 1; i < TotalParticipants; i++)
{
for(int j = 0; j < TotalParticipants-i; j++)//for j=1, 0<no of teams-1,I+1..
{
tmp = (i-1)*TotalParticipants-i*(i-1)/2+j;//tmp value
if( (tmp/5 +1) % 2 == 1)
{
tmpTeam = ((Team)List.get(j));//tmpteam = teamlist get team j
tmpTeam.setHomeGames(tmpTeam.getHome()+1);//tmpteam calls homegames method and adds one
game[tmp][0] = tmpTeam.getNum();//gets number of team
tmpTeam = ((Team)List.get(j+i));//tmpteam = teamlist get team j+i
tmpTeam.setAwayGames(tmpTeam.getAway()+1);//tmpteam calls awaygames method and adds one
game[tmp][1] = ((Team)List.get(j+i)).getNum();//gets number of team
}
else
{
tmpTeam = ((Team)List.get(j+i));//tmpteam = teamlist get team j+i
tmpTeam.setHomeGames(tmpTeam.getHome()+1);//tmpteam calls homegames method and adds one
game[tmp][0] = tmpTeam.getNum();//gets number of team
tmpTeam = ((Team)List.get(j));//tmpteam = teamlist get team j
tmpTeam.setAwayGames(tmpTeam.getAway()+1);//tmpteam calls awaygames method and adds one
game[tmp][1] = ((Team)List.get(j)).getNum();//gets number of team
}
game[tmp][2] = -1;//sets bye
}
}
}
>

