Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this exercise, you will design a set of classes that work together to simulate a parking officer checking a parked car issuing a parking

For this exercise, you will design a set of classes that work together to simulate a parking officer checking a parked car issuing a parking ticket if there is a parking violation. Here are the classes that need to collaborate:

The ParkedCar class: This class should simulate a parked car. The car has a make, model, color, license number.

The ParkingMeter class: This class should simulate a parking meter. The class has three parameters:

A 5-digit ID that identifies the meter.

A reference to the car (ParkedCar object) that is currently parked at the meter. If

no car is parked, this parameter should be set to null (in this case, make sure to

return Car: none in your toString method).

Whether the meter has expired or not.

The current time (you may simulate the current time).

The ParkingTicket class: This class should simulate a parking ticket. The class should report:

The make, model, color and license number of the illegally parked car.

Meter ID

The current time.

The amount of fine, which is $25 if the meter has expired and the current time is

between 9 a.m. and 5 p.m. and $10 if the meter has expired and the current time is between 5.01 p.m. and 8.59 a.m.

The name and badge number of the police officer issuing the ticket (DO NOT store ParkingOfficer object).

The ParkingOfficer class: This class should simulate a parking officer inspecting parked cars. The class has Officers name and badge number isExpired method that examines the ParkingMeter object and determines

whether the meter has expired. A method that examines the given parking meter and returns a parking ticket

(generates a ParkingTicket object) if the meter has expired. If it is not expired or no car is parked at the meter, return null value.

You may include instance variables and public interfaces in each class as you may find appropriate. Also add appropriate error checks.

Write a client program that demonstrates how these classes collaborate. In addition, you should create a UML diagram for demonstrating relationship among the classes and submit that UML as part of your submission.

Here are some examples of your output. They need not be exactly as shown. Feel free to be creative, but you should test your program for all cases.

Parking Meter: 34521 Time: 8.00 p.m. No car parked. 
Parking Meter: 45673 Time: 4.54 p.m. Car Parked: Lexus ES350, Black, ABC123 Meter: Not expired 
Parking Meter: 98764 Time: 5.01 p.m. Car Parked: Toyota Camry, Red, EFL786 Meter: Expired 
Parking Ticket Issued Toyota Camry, Red, EFL786 Meter ID: 98764 Time: 5.01 p.m. Fine Amount: $10 Issuing Officer: G.Bertrand, IO5674 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MFDBS 89 2nd Symposium On Mathematical Fundamentals Of Database Systems Visegrad Hungary June 26 30 1989 Proceedings

Authors: Janos Demetrovics ,Bernhard Thalheim

1989th Edition

3540512519, 978-3540512516

More Books

Students also viewed these Databases questions

Question

What physical locations do you work in?

Answered: 1 week ago