-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
69 changed files
with
924 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Parking Lot Design | ||
## Problem Statement | ||
You own a parking lot of tech center where multiple company offices are co-located. You've design a parking space management system so as different companies cars/bikes can be parked in allocated slots. The employee of specific company should collect a ticket on entrance(if parking space is available) and pay the amount on exit from parking space. | ||
|
||
## System Requirements | ||
#### Vehicle Type | ||
1. Two wheeler - bikes | ||
2. Four wheeler - cars | ||
|
||
#### Levels on parking space | ||
The parking space can have multiple floors/levels | ||
|
Binary file added
BIN
+3.64 KB
LowLevelDesign/ParkingLot/out/production/ParkingLot/ParkingLotApplication.class
Binary file not shown.
Binary file added
BIN
+654 Bytes
...ut/production/ParkingLot/com/msdeepsingh/parkinglot/exception/NonRetryableException.class
Binary file not shown.
Binary file added
BIN
+645 Bytes
...t/out/production/ParkingLot/com/msdeepsingh/parkinglot/exception/RetryableException.class
Binary file not shown.
Binary file added
BIN
+571 Bytes
...ingLot/out/production/ParkingLot/com/msdeepsingh/parkinglot/model/gate/EntranceGate.class
Binary file not shown.
Binary file added
BIN
+559 Bytes
...ParkingLot/out/production/ParkingLot/com/msdeepsingh/parkinglot/model/gate/ExitGate.class
Binary file not shown.
Binary file added
BIN
+1.23 KB
...kingLot/out/production/ParkingLot/com/msdeepsingh/parkinglot/model/gate/ParkingGate.class
Binary file not shown.
Binary file added
BIN
+3.58 KB
...Lot/out/production/ParkingLot/com/msdeepsingh/parkinglot/model/parking/ParkingFloor.class
Binary file not shown.
Binary file added
BIN
+1.21 KB
...t/production/ParkingLot/com/msdeepsingh/parkinglot/model/parking/ParkingFloorNumber.class
Binary file not shown.
Binary file added
BIN
+1.87 KB
...ngLot/out/production/ParkingLot/com/msdeepsingh/parkinglot/model/parking/ParkingLot.class
Binary file not shown.
Binary file added
BIN
+2.27 KB
...gLot/out/production/ParkingLot/com/msdeepsingh/parkinglot/model/parking/ParkingSpot.class
Binary file not shown.
Binary file added
BIN
+1.14 KB
.../out/production/ParkingLot/com/msdeepsingh/parkinglot/model/parking/ParkingSpotType.class
Binary file not shown.
Binary file added
BIN
+3.08 KB
.../production/ParkingLot/com/msdeepsingh/parkinglot/model/parkingticket/ParkingTicket.class
Binary file not shown.
Binary file added
BIN
+1.22 KB
...ction/ParkingLot/com/msdeepsingh/parkinglot/model/parkingticket/ParkingTicketStatus.class
Binary file not shown.
Binary file added
BIN
+443 Bytes
...arkingLot/out/production/ParkingLot/com/msdeepsingh/parkinglot/model/payment/Amount.class
Binary file not shown.
Binary file added
BIN
+571 Bytes
...gLot/out/production/ParkingLot/com/msdeepsingh/parkinglot/model/payment/CardPayment.class
Binary file not shown.
Binary file added
BIN
+571 Bytes
...gLot/out/production/ParkingLot/com/msdeepsingh/parkinglot/model/payment/CashPayment.class
Binary file not shown.
Binary file added
BIN
+1.11 KB
...Lot/out/production/ParkingLot/com/msdeepsingh/parkinglot/model/payment/CurrencyType.class
Binary file not shown.
Binary file added
BIN
+678 Bytes
...rkingLot/out/production/ParkingLot/com/msdeepsingh/parkinglot/model/payment/Payment.class
Binary file not shown.
Binary file added
BIN
+1.17 KB
...ot/out/production/ParkingLot/com/msdeepsingh/parkinglot/model/payment/PaymentStatus.class
Binary file not shown.
Binary file added
BIN
+1.1 KB
...gLot/out/production/ParkingLot/com/msdeepsingh/parkinglot/model/payment/PaymentType.class
Binary file not shown.
Binary file added
BIN
+630 Bytes
.../ParkingLot/out/production/ParkingLot/com/msdeepsingh/parkinglot/model/vehicle/Bike.class
Binary file not shown.
Binary file added
BIN
+626 Bytes
...n/ParkingLot/out/production/ParkingLot/com/msdeepsingh/parkinglot/model/vehicle/Car.class
Binary file not shown.
Binary file added
BIN
+1.67 KB
...rkingLot/out/production/ParkingLot/com/msdeepsingh/parkinglot/model/vehicle/Vehicle.class
Binary file not shown.
Binary file added
BIN
+1.1 KB
...gLot/out/production/ParkingLot/com/msdeepsingh/parkinglot/model/vehicle/VehicleType.class
Binary file not shown.
Binary file added
BIN
+1 KB
...gLot/out/production/ParkingLot/com/msdeepsingh/parkinglot/service/ParkingLotService.class
Binary file not shown.
Binary file added
BIN
+4.34 KB
...production/ParkingLot/com/msdeepsingh/parkinglot/service/impl/ParkingLotServiceImpl.class
Binary file not shown.
Binary file added
BIN
+292 Bytes
...out/production/ParkingLot/com/msdeepsingh/parkinglot/service/parking/ParkingService.class
Binary file not shown.
Binary file added
BIN
+731 Bytes
...ction/ParkingLot/com/msdeepsingh/parkinglot/service/parking/impl/ParkingServiceImpl.class
Binary file not shown.
Binary file added
BIN
+399 Bytes
...t/out/production/ParkingLot/com/msdeepsingh/parkinglot/service/ticket/TicketService.class
Binary file not shown.
Binary file added
BIN
+833 Bytes
...duction/ParkingLot/com/msdeepsingh/parkinglot/service/ticket/impl/TicketServiceImpl.class
Binary file not shown.
Binary file added
BIN
+780 Bytes
...kingLot/out/production/ParkingLot/com/msdeepsingh/parkinglot/utility/ParkingUtility.class
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import com.msdeepsingh.parkinglot.model.gate.EntranceGate; | ||
import com.msdeepsingh.parkinglot.model.gate.ExitGate; | ||
import com.msdeepsingh.parkinglot.model.parking.*; | ||
import com.msdeepsingh.parkinglot.model.parkingticket.ParkingTicket; | ||
import com.msdeepsingh.parkinglot.model.vehicle.Vehicle; | ||
import com.msdeepsingh.parkinglot.model.vehicle.VehicleType; | ||
import com.msdeepsingh.parkinglot.service.impl.ParkingLotServiceImpl; | ||
import com.msdeepsingh.parkinglot.service.ticket.impl.TicketServiceImpl; | ||
import com.msdeepsingh.parkinglot.utility.ParkingUtility; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
|
||
public class ParkingLotApplication { | ||
public static void main(String[] args) { | ||
System.out.println("Welcome to Parking Lot!"); | ||
|
||
ParkingLot parkingLot = ParkingLot.getParkingLot(); | ||
|
||
ParkingLotServiceImpl parkingLotService = new ParkingLotServiceImpl(parkingLot); | ||
TicketServiceImpl ticketService = new TicketServiceImpl(); | ||
|
||
//create parking spots | ||
Map<Long, ParkingSpot> parkingSpotMap = new HashMap<>(); | ||
parkingSpotMap.put(1L, parkingLotService.addParkingSpot(ParkingUtility.createParkingSpot(1L, ParkingSpotType.FOUR_WHEELER), ParkingFloorNumber.GROUND)); | ||
parkingSpotMap.put(3L, parkingLotService.addParkingSpot(ParkingUtility.createParkingSpot(2L, ParkingSpotType.TWO_WHEELER), ParkingFloorNumber.GROUND)); | ||
parkingSpotMap.put(4L, parkingLotService.addParkingSpot(ParkingUtility.createParkingSpot(3L, ParkingSpotType.FOUR_WHEELER), ParkingFloorNumber.GROUND)); | ||
parkingSpotMap.put(5L, parkingLotService.addParkingSpot(ParkingUtility.createParkingSpot(4L, ParkingSpotType.TWO_WHEELER), ParkingFloorNumber.GROUND)); | ||
|
||
//create entry and entrance gate for ground floor | ||
EntranceGate entranceGate = new EntranceGate(1L, ParkingFloorNumber.GROUND, true); | ||
ExitGate exitGate = new ExitGate(2L, ParkingFloorNumber.GROUND, true); | ||
Map<Long, EntranceGate> entranceGateMap = new HashMap<>(); | ||
entranceGateMap.put(1L, entranceGate); | ||
|
||
Map<Long, ExitGate> exitGateMap = new HashMap<>(); | ||
exitGateMap.put(2L, exitGate); | ||
|
||
|
||
//create Parking Floors | ||
Map<ParkingFloorNumber, ParkingFloor> parkingFloorMap = new HashMap<>(); | ||
ParkingFloor groundParkingFloor = new ParkingFloor(ParkingFloorNumber.GROUND, parkingSpotMap, entranceGateMap, exitGateMap); | ||
parkingFloorMap.put(ParkingFloorNumber.GROUND, groundParkingFloor); | ||
|
||
//Initialize parking Lot with name identifier and parking floors information | ||
parkingLot.setParkingLotId(UUID.randomUUID().toString()); | ||
parkingLot.setParkingLotName("Mandeep ka parking lot"); | ||
parkingLot.setParkingFloorMap(parkingFloorMap); | ||
|
||
//create vehicle | ||
Vehicle myHondaCar = new Vehicle("binaNumberWaliGadi", VehicleType.CAR); | ||
Vehicle myHeroWaliMotorCycle = new Vehicle("127.0.0.1", VehicleType.BIKE); | ||
|
||
//getParkingTicket | ||
ParkingTicket carTicket = ticketService.getParkingTicket(myHondaCar, 1L); | ||
System.out.println("Ticket generated successfully for vehicle: "+myHondaCar.getVehicleNo()); | ||
System.out.println("Ticket Details: "+carTicket); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...evelDesign/ParkingLot/src/com/msdeepsingh/parkinglot/exception/NonRetryableException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.msdeepsingh.parkinglot.exception; | ||
|
||
public class NonRetryableException extends RuntimeException { | ||
private String message; | ||
|
||
public NonRetryableException(String message) { | ||
this.message = message; | ||
} | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
public void setMessage(String message) { | ||
this.message = message; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
LowLevelDesign/ParkingLot/src/com/msdeepsingh/parkinglot/exception/RetryableException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.msdeepsingh.parkinglot.exception; | ||
|
||
public class RetryableException extends RuntimeException { | ||
private String message; | ||
|
||
public RetryableException(String message) { | ||
this.message = message; | ||
} | ||
|
||
@Override | ||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
public void setMessage(String message) { | ||
this.message = message; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
LowLevelDesign/ParkingLot/src/com/msdeepsingh/parkinglot/model/gate/EntranceGate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.msdeepsingh.parkinglot.model.gate; | ||
|
||
import com.msdeepsingh.parkinglot.model.parking.ParkingFloorNumber; | ||
|
||
public class EntranceGate extends ParkingGate { | ||
|
||
public EntranceGate(long gateNo, ParkingFloorNumber floorNo, boolean isOpen) { | ||
super(gateNo, floorNo, isOpen); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
LowLevelDesign/ParkingLot/src/com/msdeepsingh/parkinglot/model/gate/ExitGate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.msdeepsingh.parkinglot.model.gate; | ||
|
||
import com.msdeepsingh.parkinglot.model.parking.ParkingFloorNumber; | ||
|
||
public class ExitGate extends ParkingGate { | ||
|
||
public ExitGate(long gateNo, ParkingFloorNumber floorNo, boolean isOpen) { | ||
super(gateNo, floorNo, isOpen); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
LowLevelDesign/ParkingLot/src/com/msdeepsingh/parkinglot/model/gate/ParkingGate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.msdeepsingh.parkinglot.model.gate; | ||
|
||
import com.msdeepsingh.parkinglot.model.parking.ParkingFloorNumber; | ||
|
||
public abstract class ParkingGate { | ||
/** | ||
* For unique representation of gates across the floor, the gate numbers are not repeated. | ||
* */ | ||
private long gateNo; | ||
private ParkingFloorNumber floorNo; | ||
private boolean isOpen; | ||
|
||
public ParkingGate(long gateNo, ParkingFloorNumber floorNo, boolean isOpen) { | ||
this.gateNo = gateNo; | ||
this.floorNo = floorNo; | ||
this.isOpen = isOpen; | ||
} | ||
|
||
public long getGateNo() { | ||
return gateNo; | ||
} | ||
|
||
public void setGateNo(long gateNo) { | ||
this.gateNo = gateNo; | ||
} | ||
|
||
public ParkingFloorNumber getFloorNo() { | ||
return floorNo; | ||
} | ||
|
||
public void setFloorNo(ParkingFloorNumber floorNo) { | ||
this.floorNo = floorNo; | ||
} | ||
|
||
public boolean isOpen() { | ||
return isOpen; | ||
} | ||
|
||
public void setOpen(boolean open) { | ||
isOpen = open; | ||
} | ||
} |
Oops, something went wrong.