package srp

// TaxCalculatorFunc is a function-type for calculating taxes.
type TaxCalculatorFunc func(p Product) float64

type Product struct {
	Name  string
	Price float64
}

type Position struct {
	Count   int
	Product Product
}
type ShoppingCard struct {
	Positions []Position
}

func (sc *ShoppingCard) Price(calculatorFunc TaxCalculatorFunc) float64 {

	var price = 0.0
	for _, position := range sc.Positions {
		price += position.Product.Price
		price += calculatorFunc(position.Product) * float64(position.Count)
	}

	return price
}
