parking

package
v0.0.0-...-dd310bf Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2019 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddNewParking

func AddNewParking(cfg Config) error

func FreeParkingSlot

func FreeParkingSlot(parkingName string, floorNo int, slotNo int) error

func GetAllCarRegNoByColour

func GetAllCarRegNoByColour(parkingName string, colour string) ([]string, error)

func GetAllSlotsByColour

func GetAllSlotsByColour(parkingName string, colour string) ([]string, error)

func GetSlotNoByReg

func GetSlotNoByReg(parkingName string, reg string) ([]string, error)

func Status

func Status(parkingName string) ([]string, error)

Types

type Car

type Car struct {
	Type   CarType
	RegID  string
	Colour string
}

Car is just a default concrete representation of vehicle.

func (Car) GetColor

func (c Car) GetColor() string

func (Car) GetRegNO

func (c Car) GetRegNO() string

func (Car) GetType

func (c Car) GetType() CarType

func (*Car) Park

func (c *Car) Park(parkingName string) (Ticket, error)

type CarType

type CarType int
const (
	CAR       CarType = 0
	MOTORBIKE CarType = 1
	SEDAN     CarType = 2
	SUV       CarType = 3
	TRUCK     CarType = 4
	BUS       CarType = 5
)

Default -> Its only to simplify as in given problem no vehicle type is mentioned Eventualy vehicle type can be extended for different vehicle types.

type Config

type Config struct {
	Name   string        `json:"parking_name"`
	Floors []FloorConfig `json:"floors"`
}

func GetMultiFloorParkingConfig

func GetMultiFloorParkingConfig(configJson string) Config

GetMultiFloorParkingConfig

func GetSimpleParkingConfig

func GetSimpleParkingConfig(size int) Config

GetSimple, well this is to considered the fact that, for this assignment input is only parking Size

type FloorConfig

type FloorConfig struct {
	Total int           `json:"total"`
	Space []SpaceConfig `json:"space"`
}

type IVehicle

type IVehicle interface {
	Park(parkingName string) (Ticket, error)
	GetType() CarType
	GetRegNO() string
	GetColor() string
}

type SlotType

type SlotType int
const (
	DEFAULT        SlotType = 0
	TWO_WHEELER    SlotType = 1
	FOUR_WHEELER   SlotType = 2
	BIG_VEHIHLE    SlotType = 3
	TotalSlotTypes SlotType = 4
)

Default -> Its only to simplify as in given problem no parking space type is mentioned. Eventualy the parking slot can be extended for different slot types.

func (*SlotType) UnmarshalJSON

func (s *SlotType) UnmarshalJSON(b []byte) error

type SpaceConfig

type SpaceConfig struct {
	From int      `json:"from"`
	To   int      `json:"to"`
	Type SlotType `json:"type"`
}

type Ticket

type Ticket struct {
	No          uuid.UUID
	ParkingName string
	Floor       int // Which floor
	Slot        int // Which spot
	EntryTime   time.Time
	ExitTime    time.Time
	State       TicketStatus
	Charge      int
}

func AssignTicket

func AssignTicket(parkingName string, car IVehicle) (Ticket, error)

type TicketStatus

type TicketStatus int
const (
	ACTIVE TicketStatus = 0
)

Jump to

Keyboard shortcuts

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