Documentation
¶
Index ¶
- Constants
- type Cart
- func (c Cart) AddItem(id string) error
- func (c Cart) ApplyPromotions() (float32, string)
- func (c Cart) BuyXGetYFree(x, y string) (float32, string)
- func (c Cart) Checkout()
- func (c Cart) OverXDiscountY(x int, y float32, id string) float32
- func (c Cart) ScannedItemsLabels() string
- func (c Cart) ScannedItemsTotalPrices() float32
- func (c Cart) XForPriceOfY(x, y int, id string) float32
- type Inventory
- type Product
- type ProductDetails
Constants ¶
const NoItemsInCart = "No items in shopping cart"
NoItemsInCart is the fixed message for logging when a cart has zero items
const OutOfStock = "Out of stock"
OutOfStock is the fixed message for logging when an item is out of stock
const ZeroItemCountInCart = "Item with zero count in cart"
ZeroItemCountInCart is the fixed message for logging when a cart has an item with zero items added
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cart ¶
Cart contains a map of items to item count
func (Cart) AddItem ¶
AddItem adds a product id to the shopping cart. If one already exists it increments this number
func (Cart) ApplyPromotions ¶
func (Cart) BuyXGetYFree ¶
BuyXGetYFree will add items to the cart.
func (Cart) Checkout ¶
func (c Cart) Checkout()
Checkout prints the final listing of contents and the total price of the shopping cart
func (Cart) OverXDiscountY ¶
OverXDiscountY will check that there are more than X items of ID and then apply Y discount
func (Cart) ScannedItemsLabels ¶
ScannedItemsLabels returns a slice of product names from the shopping cart
func (Cart) ScannedItemsTotalPrices ¶
ScannedItemsTotalPrices returns the float32 sum of all products in the shopping cart
type Product ¶
type Product struct { Details ProductDetails Stock int }
Product is a container for a product item and its stock level
type ProductDetails ¶
ProductDetails contains the product details