CS 1054 Introduction to Programming in Java (Spring 2008)

Lab 9: Arrays and array lists

Lab Objectives

Instructions

  1. There will be no webcat submission for this week's lab, but attendance will be checked. You get twenty points for just paying attention. The TA will walk you through most of the tasks, but you will be given some time to implement some methods yourself.
  2. Begin by downloading Lab9.zip, save the file, and then extract it in a folder you can locate. Open this project in BlueJ. Make sure all classes (GradeRecord, ReportCard, and ReportCardTester) are compiled.
  3. We can view a ReportCard as an aggregate class: a ReportCard object consists of multiple GradeRecord objects. ReportCardTester creates several ReportCard objects and adds, updates, and accesses the grade records contained in these objects. Study ReportCardTester and execute it, and make sense of the output it produces.
  4. ReportCard is implemented as containing an array of GradeRecord objects. As it stands, it is a complete, fully working class.
  5. The next step is to revise ReportCard so that it uses an array list instead. Note that ReportCardTester and GradeRecord will not be revised.
  6. Begin by "stubbing" all the methods of the ReportCard class; delete all the method contents so that only curly braces remain for each method; don't delete the actual method headers/signatures. Delete the instance fields for ReportCard as well.
  7. The only instance field needed for this revised ReportCard class is an array list. Add this instance field.
  8. Update the methods so that they operate on that array list instead.