Untitled
Object-Oriented Programming and Design Tutorial
Consider the following simplified description of a parking enforcement scheme
run by Sleepy Town Council:
• Parking attendants (PAs) issue two kinds of parking fines to illegally parked
vehicles: Fixed Penalty fines and Excess Charge fines.
• A PA may issue a Fixed Penalty fine when a vehicle is illegally parked at a
location other than a parking meter. The PA must fill in on the Fixed Penalty fine
the date and time of the offence, the offence code (an integer), and the
registration number of the vehicle. The amount of the fine is set by the council,
and is the same for all Fixed Penalty fines. Initially this is £100.
• A PA may issue an Excess Charge fine when a vehicle has overstayed (i.e.
exceeded) paid-for time at a parking meter. The PA must fill in on the Excess
Charge fine the date and time, the offence code, the registration number of the
vehicle, and the number of minutes of overstay. The amount of the fine is £20
plus £5 for every minute of overstay, but the total amount cannot exceed that of
a Fixed Penalty fine.
• PAs are uniquely identified by a badge number. They receive a salary plus a
bonus payment. Specifically, Senior PAs are paid a salary of £1200 plus a bonus
of 10% of the value of all fines they have issued. Junior PAs are paid a salary of
£900 plus a bonus of 5% of the value of all fines they have issued.
a Draw a UML class diagram to describe the above.
b Write C++ class declarations (i.e. no function bodies) to support the above.
c Write a test function where:
– Senior parking attendant Charon (badge number 666) issues a Fixed
Penalty fine on 16/02/2006 at 09h50 to a vehicle (reg. “LO52RNA”)
illegally parked on the pavement (offence code 26).
– Sleepy Town Council decides that the amount payable for all Fixed Penalty
fines should be £120.
– Junior parking attendant Nelson (badge number 111) issues an Excess
Charge fine on 17/02/2006 at 10h15 to a vehicle (reg. “B14NCA”) that has
overstayed at a parking meter by 15 minutes (offence code 14).
– Nelson’s salary is calculated.
d Write the bodies of the functions from part (b) that relate to your classes that
represent parking attendants and parking fines.