model

package
v0.0.0-...-6746b86 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2019 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package basket provides a representation for a online eshop basket

Package promotion declares cabify promotion strategies

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Basket

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

func NewBasket

func NewBasket() *Basket

func (*Basket) AddProduct

func (b *Basket) AddProduct(p *Product)

func (*Basket) GetAllProducts

func (b *Basket) GetAllProducts() []*Product

func (*Basket) GetDiscountAmmount

func (b *Basket) GetDiscountAmmount() float64

func (*Basket) GetTotalAmmount

func (b *Basket) GetTotalAmmount() float64

func (*Basket) RefreshDiscount

func (b *Basket) RefreshDiscount()

func (*Basket) RemoveProduct

func (b *Basket) RemoveProduct(p *Product)

type BasketHelper

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

type BasketProduct

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

type BulkDiscount

type BulkDiscount struct {
	Code     string
	Quantity int
	NewPrice float64
}

func (*BulkDiscount) CalculateAmmount

func (bd *BulkDiscount) CalculateAmmount(b *Basket)

type DiscountCalculator

type DiscountCalculator interface {
	CalculateAmmount(b *Basket)
}

type FreeProduct

type FreeProduct struct {
	Code string
}

freeProduct specifies promotions of the type 2x1

func (*FreeProduct) CalculateAmmount

func (fp *FreeProduct) CalculateAmmount(b *Basket)

type Product

type Product struct {
	Code     string  `json:"code"`
	Name     string  `json:"name"`
	Price    float64 `json:"price"`
	Discount float64 `json:"-"`
}

Product is a product representation of a cabify product

Jump to

Keyboard shortcuts

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