Exercise 3 [20 marks]
Your next task is to develop a ParkingTariff class. The primary objective is actually to develop a
TariffTable, however, there's a design issue that must be solved first.
A TariffTable must store a series of parking tariffs. Each is an association between a time period and
a cost. You could implement a TariffTable by using two arrays, one containing TimePeriod objects
and the other containing Money objects, where the TimePeriod at index i in the first array is
associated with the Money object at index I in the second array.
CONTINUED
That's not a particularly nice solution since there's nothing in the resulting variable declarations to
indicate the relationship, and there's potential for mismatch. A better solution is to have a
TariffTable contain a collection of ParkingTariff objects, where each ParkingTariff object stores a
TimePeriod and Money.
Develop a ParkingTariff class of object.
Your class will have instance variable(s), constructor(s), and method(s).
You should aim to move beyond simple get and set methods to ones that offer greater
functionality.
With respect to the second point, you may wish to develop the ParkingTariff class in conjunction
with the TariffTable class (exercise 3):
Think about what a TariffTable object must do.
Think about what could be delegated to ParkingTariff objects
Evaluate your work by (i) writing a test program, or (ii) writing Junit tests, or (iii) using the jGrasp
interactive feature.
Your solution will be manually marked by the tutors.
9