|
Download task_046/instruction.md from Lego-X/UXInteract: direct link, hf CLI and curl.
- Browser
- Download file 1.75 kB
-
https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_046/instruction.md
- Command line
-
hf download hf://datasets/Lego-X/UXInteract/task_046/instruction.md
-
curl -L -o instruction.md https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_046/instruction.md
1.75 kB
Compose e-commerce promotion strategies
Implement the promotion calculator in the supplied Go project, using its promotion package. Work offline and keep go test ./... passing. Local helper packages are allowed.
Interface
Keep the supplied Order{OriginalAmount float64, UserLevel string, Category string}, Strategy interface with Discount(Order) float64, and NewPromotionCalculator(strategies ...Strategy) *PromotionCalculator with FinalAmount(Order) float64. Provide the concrete strategies below.
Discount rules
| Strategy | Discount from the original amount |
|---|---|
FullReductionStrategy |
¥100 at ¥1,000 or more, otherwise ¥50 at ¥500 or more, otherwise ¥20 at ¥200 or more, otherwise zero. Only the highest qualifying tier applies. |
UserLevelDiscountStrategy |
bronze: 0%; silver: 5%; gold: 10%; platinum: 15%. |
CategoryDiscountStrategy |
electronics: 8%; clothing: 12%; books: 20%. |
Unknown or empty levels and categories get zero discount from the corresponding strategy. Amounts are finite, nonnegative floating-point numbers, including fractional amounts; the results must be finite.
Acceptance Checklist
- Each configured strategy computes its discount for the original order, not for a running balance. Full reductions respect inclusive thresholds, and percentage rules also work at non-round amounts.
- A calculator accepts additional implementations through
Strategywithout needing changes to built-in strategies. Apply each supplied strategy once; sum the discounts independently of their order. - Return the original amount with no strategies and zero when discounts exceed the amount. Zero and unknown/empty classifications do not create spurious discounts.