Download task_046/environment/code/promotion.go from Lego-X/UXInteract: direct link, hf CLI and curl.
- Browser
- Download file 920 Bytes
-
https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_046/environment/code/promotion.go
- Command line
-
hf download hf://datasets/Lego-X/UXInteract/task_046/environment/code/promotion.go
-
curl -L -o promotion.go https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_046/environment/code/promotion.go
920 Bytes
| package promotion | |
| type Order struct { | |
| OriginalAmount float64 | |
| UserLevel string | |
| Category string | |
| } | |
| type Strategy interface { | |
| Discount(order Order) float64 | |
| } | |
| type PromotionCalculator struct { | |
| strategies []Strategy | |
| } | |
| func NewPromotionCalculator(strategies ...Strategy) *PromotionCalculator { | |
| return &PromotionCalculator{strategies: strategies} | |
| } | |
| func (p *PromotionCalculator) FinalAmount(order Order) float64 { | |
| // TODO: implement by summing discounts from original amount. | |
| return order.OriginalAmount | |
| } | |
| type FullReductionStrategy struct{} | |
| func (FullReductionStrategy) Discount(order Order) float64 { return 0 } | |
| type UserLevelDiscountStrategy struct{} | |
| func (UserLevelDiscountStrategy) Discount(order Order) float64 { return 0 } | |
| type CategoryDiscountStrategy struct{} | |
| func (CategoryDiscountStrategy) Discount(order Order) float64 { return 0 } | |