A Java API for parking plazza.
The project is built with Gradle.
Simply checkout the project and from bash run following gradle command to setup dev env. for eclipse:
./gradlew eclipse
Once run, import the project in Eclipse using the "Import Existing Project" option (File -> Import -> Existing Project From Workspace).
./gradlew tasks
To package and release a jar, run the fatJar
gradle task.
./gradlew fatJar
With the above command, the jar will be placed under build\libs
.
The BOM for project is under package com.pp.bom
. Following BOM have been added (in alphabetical order):
Address
: Represnts an address.Car
: A class representing a car (can be a abstract class or an abstract classVehicle
can be added of thisCar
could be an extenstion), which may need a parking slot in the parking plazza. The constructor ofCar
class needs two arguments:id
: Which can't be emtpy, else throw anIllegalArgumentException
.type
:CarEnumType
Car car = new Car(id, CarEnumType.GASOLINE);
CarEnumType
: Enums to represent car types.- ParkingRate: An interface to define a pricing policy. Following imlementation exist and others can be added:
HourlyParkingRate
HourlyWithFixedParkingRate
MinuteBasedPricing
: This one existing out of BOM representing an external pricing defined which can later be used in TollParking.
- ParkingSlot: An Abstract to represent a Parking slot. They are added when a
TollParking
object is instantiated. Following extenstions exist and more may be added depending on the need: - ParkingTicket: This is created everytime a
ParkingSlot
is assigned to aCar
. The constructor and all the setters areprotected
to protect the instantiation. Each parking ticket gets a unique ID. Following methods are publically accessible:getId()
getCar()
getSlot()
getEntryDateTime()
getExitDateTime()
getBillingAmount()
isBillPaid()
TollParking
: Contains all the business logic for the operating the parking plazza. To instantiate an object of this class,
Address lotAddress = new Address("Route de Nice", "Antibes", "06600", "FR");
HashMap<CarTypeEnum, Integer> slotCapacity = new HashMap<CarTypeEnum, Integer>();
slotCapacity.put(CarTypeEnum.GASOLINE, 4);
slotCapacity.put(CarTypeEnum.ELECTRIC_20KW, 2);
slotCapacity.put(CarTypeEnum.ELECTRIC_50KW, 1);
ParkingRate rate = new ParkingRate.HourlyWithFixedParkingRate(1,20);
TollParking parking = new TollParking("Hello Parking LOT", address, slotCapacity, rate)
- Following methods are exposed through
TollParking
:parking.reqestParking(car)
: To request a parking slot for the given car.parking.exitParking(Car)
: exit the parking, This will return a ticketID which can be used to access the parking tickets, amount to be paid, record payment.parking.getBillingAmount(ticketId)
parking.isBillPaid(ticketId)
: Check is given bill id has been paid or not?parking.payBill(ticketId)
: Records that payment has been done for given bill ID.parking.getAllUnPaidBill()
: Get a table with ticketId, car ID and billing amount.
Refer to TollParkingTest.java for test code.