1.3-Object-Georienteerd-Programmeren

Parking garage

In this assignment, we are going to model the administration system of a parking garage. Our parking garage has only two types of parking spots: for cars and for motorcycles.

The number of spots for cars and, the number of spots for motorcycles can be set during the instantiation of a parking garage and cannot be altered after it has been set initially.

A car and a motorcycle both have a license plate, a start date/time (the moment they enter the parking garage) and, an end date/time (the moment they drive away and have paid). As soon as a car or a motorcycle drives away, a parking spot becomes available for a next customer, but we still store the actual object in our archive so that we can determine (in retrospect) what the total earnings are of the parking garage.

The rates for a car and a motorcycle are different:

You only have to charge for whole hours. (So, 0-59 minutes parking is free, 60-119 minutes is 1 hour, etc.) It doesn’t matter whether you park during the day or at night, the costs are always calculated in the same way.

If a car or motorcycle wants to enter the parking garage, but the garage is full then a (self defined) ParkingGarageException is thrown.

Make sure the parking garage has methods to:

To get you started, we have provided an Application class (click here to download it) with example code to give you an idea on how to test your application. Note that we have left out all other classes for you to create.

In addition, we have provided a VehicleCreator class (click here to download it) which contains some tools to easily create some example vehicles. Be sure to look at the official Java documentation for the descriptions of the methods we use here if you have any doubts what certain code actually does!