College is implemented by objects that
store information about colleges and universities. The interface
declares methods for accessing a College object's name,
tuition, and the region in which it is located. The interface also
specifies constants for naming the regions.
The class CollegeGroup stores information about a group of
colleges/universities. Part of the CollegeGroup class
declaration is shown below.
The following chart shows an example of colleges/universities that could
appear in an object of type CollegeGroup.
| Name | Region | Tuition | |
|---|---|---|---|
| 0 | Colgate University | Northeast | $27,025 |
| 1 | Duke University | Southeast | $26,000 |
| 2 | Kalamazoo College | Midwest | $19,764 |
| 3 | Stanford University | West | $25,917 |
| 4 | Florida International University | Southeast | $10,800 |
| 5 | Dartmouth College | Northeast | $27,764 |
| 6 | Spelman College | Southeast | $11,455 |
CollegeGroup method updateTuition,
which is described as follows. Method updateTuition
associates a new tution with the college whose name is passed as a
parameter. Assume that the objects stored in the array
myColleges are instances of a class
CollegeImpl that implements the College
interface and whose declaration is partially shown below.
Note that neither the College interface nor the
CollegeImpl class specify a method for changing tuition;
i.e., CollegeImpl is an immutable class.
In writing updateTuition you should create a new
CollegeImpl object for the specified college, with the same
name and region, but a new tuition. This new object should be stored in
the same location of myColleges as the original object.
Complete method updateTuition below.
| Name | Region | Tuition | |
|---|---|---|---|
| 0 | Colgate University | Northeast | $27,025 |
| 1 | Duke University | Southeast | $26,000 |
| 2 | Kalamazoo College | Midwest | $19,764 |
| 3 | Stanford University | West | $25,917 |
| 4 | Florida International University | Southeast | $10,800 |
| 5 | Dartmouth College | Northeast | $27,764 |
| 6 | Spelman College | Southeast | $11,455 |
Write the CollegeGroup method getCollegeList,
which is described as follows. Method getCollegeList
returns an ArrayList of colleges that are locted in the specified region
and whose tuition is in the range between low and
high, inclusive. The size of the ArrayList should be equal
to the number of colleges that meet the criteria of region and tuition
range.
For example, if the object colleges is an instance of the
class CollegeGroup and represents the entries shown in the
chart above, the call
list an ArrayList of two elements
containing objects representing Florida International University and
Spelman College (note that Duke University is not included because its
tuition is not in the specified range and Kalamazoo College is not
included because it is not in the specified region).
Complete the method below.