parking

package
v0.0.0-...-381b1be Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package parking :: builder.go

Package parking :: parking.go

Package parking :: regulation.go

Package parking :: spot.go

Index

Constants

View Source
const (
	// COMPACTPERCENT specifies percentage of compact spots
	COMPACTPERCENT = 20.0
	// CARPOOLPERCENT specifies percentage of carpool spots
	CARPOOLPERCENT = 7.5
	// DEFAULTCAPACITY specifies minimum total capacity for a parking garage
	DEFAULTCAPACITY = 100
	// DEFAULTHANDICAPPERCENT sepcifies percentage of handicap spots
	DEFAULTHANDICAPPERCENT = 5.0
	// DEFAULTGROUNDLEVELS specifies minimum number of ground levels
	DEFAULTGROUNDLEVELS = 0
	// DEFAULTLEVELS specifies minimum number of parking garage levels
	DEFAULTLEVELS = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder struct

func NewBuilder

func NewBuilder(capacity, levels, groundLevels int, regulation IParkingRegulation) *Builder

NewBuilder returns a parking builder

func (*Builder) Construct

func (b *Builder) Construct()

Construct initializes a Parking instance

type CityRegulation

type CityRegulation struct {
	// contains filtered or unexported fields
}

CityRegulation implements IParkingRegulation

func GetCityRegulation

func GetCityRegulation(capacity, levels, groundLevels int) CityRegulation

GetCityRegulation returns a city regulation

func (*CityRegulation) GetCarpoolCapacity

func (r *CityRegulation) GetCarpoolCapacity() int

GetCarpoolCapacity returns carpool capacity per the regulation

func (*CityRegulation) GetCompactCapacity

func (r *CityRegulation) GetCompactCapacity() int

GetCompactCapacity returns compact capacity per the regulation

func (*CityRegulation) GetHandicapCapacity

func (r *CityRegulation) GetHandicapCapacity() int

GetHandicapCapacity returns handicap capacity per the regulation

func (*CityRegulation) SetCapacities

func (r *CityRegulation) SetCapacities(capacity, levels, groundLevels int) (int, int, int)

SetCapacities returns capacity, levels, and groundLevels

type IParkingRegulation

type IParkingRegulation interface {
	SetCapacities(int, int, int) (int, int, int)
	GetCarpoolCapacity() int
	GetCompactCapacity() int
	GetHandicapCapacity() int
}

IParkingRegulation interface

type Parking

type Parking struct {
	// contains filtered or unexported fields
}

Parking struct

func New

func New(capacity, levels, groundLevels int, regulation IParkingRegulation) *Parking

New create a Parking instance with capacity, levels, and groundLevels

func (*Parking) FindAvailableSpot

func (p *Parking) FindAvailableSpot(
	isHandicap, isCarpool, isCompact bool, entryLevel int) *Spot

FindAvailableSpot returns the first best available to the entryLevel per specific handicap, carpool, or compact property of the vehical note: the caculation for the best spot assumes for the walking distance to

the entry level, instead of driving distance to the spot, since the
the parking does not specify which level is the garage entry;
otherwise, the best/first available spot would be different.

func (*Parking) Park

func (p *Parking) Park(spot *Spot)

Park occupies a specific spot

func (*Parking) SprintLevel

func (p *Parking) SprintLevel(level int) string

SprintLevel returns a parking map for specific level

func (*Parking) SprintMap

func (p *Parking) SprintMap() string

SprintMap returns a parking map

func (*Parking) String

func (p *Parking) String() string

String func for Parking

type Spot

type Spot struct {
	// contains filtered or unexported fields
}

Spot struct

func (*Spot) CompareDistance

func (s *Spot) CompareDistance(other *Spot) int

CompareDistance compares distances to entry

func (*Spot) GetLabel

func (s *Spot) GetLabel() string

GetLabel func for Spot

func (*Spot) String

func (s *Spot) String() string

String func for Spot

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL