import java.util.ArrayList;

public class Round
{
    ArrayList<Competitor> competitorList;

    public Round(String[] names)
    {
        competitorList = new ArrayList<Competitor>();

        for(int i = 0; i < names.length; i++)
            competitorList.add(new Competitor(names[i], i + 1));
    }

    public ArrayList<Match> buildMatches()
    {
        ArrayList<Match> matches = new ArrayList<Match>();

        int bestIndex = competitorList.size() % 2;
        int worstIndex = competitorList.size() - 1;

        while(bestIndex < worstIndex)
        {
            matches.add(new Match(
                    competitorList.get(bestIndex),
                    competitorList.get(worstIndex)));

            bestIndex++;
            worstIndex--;
        }

        return matches;
    }
}
