Skip to content

pranav8494/parkingPlazza

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Parking Plazza

A Java API for parking plazza.

Setup the Dev env.

The project is built with Gradle.

Setup eclipse

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).

List all build tasks:

./gradlew tasks

Package the jar:

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.

API:

BOM

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 class Vehicle can be added of this Car could be an extenstion), which may need a parking slot in the parking plazza. The constructor of Car class needs two arguments:
    • id: Which can't be emtpy, else throw an IllegalArgumentException.
    • 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 a Car. The constructor and all the setters are protected 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.

About

A Java API for parking plazza.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages