decoratorpattern

package
v0.0.0-...-0a00fa3 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCost

func GetCost(b Beverage) string

func GetName

func GetName(b Beverage) string

Types

type Beverage

type Beverage interface {
	DrinkName() string
	Cost() float64
}

func NewBeverage

func NewBeverage(name string, cost float64, bt BeverageType) Beverage

func NewCondiment

func NewCondiment(b Beverage, name string, cost float64, bt CondimentType) Beverage

type BeverageType

type BeverageType int
const (
	DARKROAST BeverageType = iota + 1
	HOUSEBLEND
	DECAF
)

type CondimentDecorator

type CondimentDecorator interface {
	Beverage
}

type CondimentType

type CondimentType int
const (
	MOCHA CondimentType = iota + 1
	WHIP
	SOY
)

type DarkRoast

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

func NewDarkRoast

func NewDarkRoast(name string, cost float64) *DarkRoast

func (*DarkRoast) Cost

func (dr *DarkRoast) Cost() float64

func (*DarkRoast) DrinkName

func (dr *DarkRoast) DrinkName() string

type Decaf

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

func NewDecaf

func NewDecaf(name string, cost float64) *Decaf

func (*Decaf) Cost

func (dc *Decaf) Cost() float64

func (*Decaf) DrinkName

func (dc *Decaf) DrinkName() string

type HouseBlend

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

func NewHouseBlend

func NewHouseBlend(name string, cost float64) *HouseBlend

func (*HouseBlend) Cost

func (hb *HouseBlend) Cost() float64

func (*HouseBlend) DrinkName

func (hb *HouseBlend) DrinkName() string

type Mocha

type Mocha struct {
	Beverage
	// contains filtered or unexported fields
}

func NewMocha

func NewMocha(b Beverage, name string, cost float64) *Mocha

func (*Mocha) Cost

func (m *Mocha) Cost() float64

func (*Mocha) DrinkName

func (m *Mocha) DrinkName() string

type Soy

type Soy struct {
	Beverage
	// contains filtered or unexported fields
}

func NewSoy

func NewSoy(b Beverage, name string, cost float64) *Soy

func (*Soy) Cost

func (s *Soy) Cost() float64

func (*Soy) DrinkName

func (s *Soy) DrinkName() string

type Whip

type Whip struct {
	Beverage
	// contains filtered or unexported fields
}

func NewWhip

func NewWhip(b Beverage, name string, cost float64) *Whip

func (*Whip) Cost

func (w *Whip) Cost() float64

func (*Whip) DrinkName

func (w *Whip) DrinkName() string

Jump to

Keyboard shortcuts

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