Other 2013 FR Questions FR other years Be Prepared Home
A-1
Part (a)
  public DownloadInfo getDownloadInfo(String title)
  {
    for (DownloadInfo di : downloadList)
      if (di.getTitle().equals(title))
         return di;
    return null;
  }

Part (b)
  public void updateDownloads(List<String> titles)
  {
    for (String title : titles)
    {
      DownloadInfo di = getDownloadInfo(title);
      if (di == null)
        downloadList.add(new DownloadInfo(title)); 1
      else
        di.incrementTimesDownloaded();
    }
  }
Notes:
  1. Notice that the comment in DownloadInfo's constructor states that it "sets the number of times downloaded to 1" — no need to increment it.

Other 2013 FR Questions | Back to Contents

Copyright © 2013 by Skylight Publishing
support@skylit.com