Round
is #3 from the from the 2025 AP Computer Science A Free Response problems.
https://apcentral.collegeboard.org/media/pdf/ap25-frq-computer-science-a.pdf
Part (a) Round
constructor
public Round(String[] names)
{
competitorList = new ArrayList<Competitor>();
for(int i = 0; i < names.length; i++)
competitorList.add(new Competitor(names[i], i + 1));
}
Part (b) buildMatches
method
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;
}
Java files with test code
Competitor.java
Match.java
Round.java
ThreeTest.java
2025 AP CS Exam Free Response Solutions
- DogWalker Free Response Solution
- SignedText Free Response Solution
- SumOrSameGame Free Response Solution
Help & comments
Get help from AP CS Tutor Brandon Horn
See an error? Question? Please comment below.