2013 AP CSA FRQ 1: MusicDownloads
Topic: ArrayList & Object Tracking
Skills: ArrayList operations, object lookup, accumulator pattern
Unit: Unit 4 (Data Collections) (2025-2026 AP CSA)
Points: 9 | Time: ~22 minutes
Part (a)
Write the getDownloadInfo method that finds a download by title.
Solution
public DownloadInfo getDownloadInfo(String title)
{
for (DownloadInfo d : downloadList)
{
if (d.getTitle().equals(title))
{
return d;
}
}
return null;
}Part (b)
Write the updateDownloads method that updates or adds download info.
Solution
public void updateDownloads(List titles)
{
for (String title : titles)
{
DownloadInfo info = getDownloadInfo(title);
if (info == null)
{
downloadList.add(new DownloadInfo(title));
}
else
{
info.incrementTimesDownloaded();
}
}
} Key Concepts
Common Mistakes
Official Resources
Author: Tanner Crow - AP CS Teacher, 11+ years