Sign in to track progress, unlock prep layers, and browse your pipeline.Sign in
Design a shopping cart with coupons and tax
Design a Shopping Cart with Coupons and Tax
Design an object-oriented shopping cart module for an e-commerce system.
Requirements:
- A cart can add items and update item quantities.
- The cart supports checkout. After checkout, the cart becomes immutable (no further changes to items/quantities/coupons).
- The cart can apply coupons. There may be multiple coupon types, for example:
- Percentage off (e.g., 20% off)
- BOGO (Buy-One-Get-One) style discounts
- The cart must compute tax based on a state tax rate.
- The prompt is intentionally vague: explain what clarifying questions you would ask, then propose a clean class/interface design and describe how totals are calculated.
Deliverables:
- Key classes and responsibilities (e.g., Cart, LineItem, Product, Pricing/Discount/Tax components).
- Core methods and data structures.
- How you prevent modification after checkout.
- How you model different coupon types and make it easy to add new ones.
AI interview prep
Core dilemma
Balancing the flexibility and extensibility required for complex business rules (coupons, tax) with the need for strict state management, immutability post-checkout, and correct calculation logic.
Mid-level signals3
Senior signals5
Red flags5
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Design a shopping cart with coupons and tax
Design a Shopping Cart with Coupons and Tax
Design an object-oriented shopping cart module for an e-commerce system.
Requirements:
- A cart can add items and update item quantities.
- The cart supports checkout. After checkout, the cart becomes immutable (no further changes to items/quantities/coupons).
- The cart can apply coupons. There may be multiple coupon types, for example:
- Percentage off (e.g., 20% off)
- BOGO (Buy-One-Get-One) style discounts
- The cart must compute tax based on a state tax rate.
- The prompt is intentionally vague: explain what clarifying questions you would ask, then propose a clean class/interface design and describe how totals are calculated.
Deliverables:
- Key classes and responsibilities (e.g., Cart, LineItem, Product, Pricing/Discount/Tax components).
- Core methods and data structures.
- How you prevent modification after checkout.
- How you model different coupon types and make it easy to add new ones.