This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: 15-121 FALL 2009 [CORTINA/REID-MILLER]LAB 3In this lab, you will build a class to implement a special array list that stores its values in increasing order. First, you will do this using the Java ArrayListclass. Then you will do this using a class that implements an array list directly using an array. EXERCISESDownload the OrderedArrayList.zipproject file. This project contains a CalendarDateclass that models a calendar date with a month, day and year (e.g. 7/4/1776). A CalendarDateimplements the Comparableinterface which requires it to have a compareTomethod. Using the compareTomethod:If we have two objects aand bthat are Comparable, then the method call a.compareTo(b)returns a positive integer if ais "greater" than b, a negative integer if ais "less" than b, or 0 if they are the same. For dates, the comparison is based on chronological ordering. Example: If ais the date 12/4/1967 and bis the date 6/29/1951, the expression a.compareTo(b)returns a positve integer since acomes after bchronologically. chronologically....
View Full Document
- Spring '09