Design Parking Lot

Step 1: Handle ambiguity and clarify your assumptions

  • How big is the parking lot?
  • Is this a single or multiple level parking lot?
  • What are the types of vehicles?
  • What kind of spots do we have?
  • Which cars can park in which spots?

Step 2: Outline use cases and constraints

  1. The parking lot has multiple levels. Each level has multiple rows of spots.
  2. The parking lot can park motorcycles, cars, and buses.
  3. The parking lot has motorcycle spots, compact spots, and large spots.
  4. A motorcycle can park in any spot.
  5. A car can park in either a single compact spot or a single large spot.
  6. A bus can park in five large spots that are consecutive and within the same row. It cannot park in small spots.

Step 3:

Draw core objects

  • We use Parking Slot class to represent the parking space
  • We use Vehicle class to represent cars
  • We need a parking lot class as the manage object
  • Because the parking lot is multilevel, we can use a level class to represent it

Analyze the relationships and draw high level design

  • Each parking space will have a reference to the vehicle
  • Each level will have many parking slots, we
  • The parking lot will have multiple level objects


results matching ""

    No results matching ""