creational

package
v0.0.0-...-2a023ee Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Cash      = 1
	DebitCard = 2
)

Our current implemented Payment methods are described here

View Source
const (
	White = 1
	Black = 2
	Blue  = 3
)

Variables

This section is empty.

Functions

func GetInstance

func GetInstance() *singleton

Types

type BikeBuilder

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

A Builder of type motorbike

func (*BikeBuilder) GetVehicle

func (b *BikeBuilder) GetVehicle() VehicleProduct

func (*BikeBuilder) SetSeats

func (b *BikeBuilder) SetSeats() BuildProcess

func (*BikeBuilder) SetStructure

func (b *BikeBuilder) SetStructure() BuildProcess

func (*BikeBuilder) SetWheels

func (b *BikeBuilder) SetWheels() BuildProcess

type BuildProcess

type BuildProcess interface {
	SetWheels() BuildProcess
	SetSeats() BuildProcess
	SetStructure() BuildProcess
	GetVehicle() VehicleProduct
}

type BusBuilder

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

A Builder of type motorbike

func (*BusBuilder) GetVehicle

func (b *BusBuilder) GetVehicle() VehicleProduct

func (*BusBuilder) SetSeats

func (b *BusBuilder) SetSeats() BuildProcess

func (*BusBuilder) SetStructure

func (b *BusBuilder) SetStructure() BuildProcess

func (*BusBuilder) SetWheels

func (b *BusBuilder) SetWheels() BuildProcess

type CarBuilder

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

A Builder of type car

func (*CarBuilder) GetVehicle

func (c *CarBuilder) GetVehicle() VehicleProduct

func (*CarBuilder) SetSeats

func (c *CarBuilder) SetSeats() BuildProcess

func (*CarBuilder) SetStructure

func (c *CarBuilder) SetStructure() BuildProcess

func (*CarBuilder) SetWheels

func (c *CarBuilder) SetWheels() BuildProcess

type CashPM

type CashPM struct{}

func (*CashPM) Pay

func (c *CashPM) Pay(amount float32) string

type DebitCardPM

type DebitCardPM struct{}

func (*DebitCardPM) Pay

func (c *DebitCardPM) Pay(amount float32) string

type ItemInfoGetter

type ItemInfoGetter interface {
	GetInfo() string
}

type ManufacturingDirector

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

Director

func (*ManufacturingDirector) Construct

func (f *ManufacturingDirector) Construct()

func (*ManufacturingDirector) SetBuilder

func (f *ManufacturingDirector) SetBuilder(b BuildProcess)

type NewDebitCardPM

type NewDebitCardPM struct{}

func (*NewDebitCardPM) Pay

func (d *NewDebitCardPM) Pay(amount float32) string

type PaymentMethod

type PaymentMethod interface {
	Pay(amount float32) string
}

PaymentMethod defines a way of paying in the shop. This factory method returns objects that implements this interface

func GetPaymentMethod

func GetPaymentMethod(m int) (PaymentMethod, error)

CreatePaymentMethod returns a pointer to a PaymentMethod object or an error if the method is not registered. We used "new" operator to return the pointer but we could also used &Type{} althought new makes it more readable for newcomers could be confusing

type Shirt

type Shirt struct {
	Price float32
	SKU   string
	Color ShirtColor
}

func (*Shirt) GetInfo

func (s *Shirt) GetInfo() string

func (*Shirt) GetPrice

func (i *Shirt) GetPrice() float32

type ShirtCloner

type ShirtCloner interface {
	GetClone(m int) (ItemInfoGetter, error)
}

func GetShirtsCloner

func GetShirtsCloner() ShirtCloner

type ShirtColor

type ShirtColor byte

type ShirtsCache

type ShirtsCache struct{}

func (*ShirtsCache) GetClone

func (s *ShirtsCache) GetClone(m int) (ItemInfoGetter, error)

type VehicleProduct

type VehicleProduct struct {
	Wheels    int
	Seats     int
	Structure string
}

Product

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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