Design a shopping cart with coupons and tax

Quick Overview

Evaluates object-oriented design, domain modeling, encapsulation/immutability, and extensible pricing/discount strategies within the Software Engineering Fundamentals domain at a component-level/class-interface design abstraction.

Design a shopping cart with coupons and tax

Company: Envoy

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: easy

Interview Round: Technical Screen

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.

Quick Answer: Evaluates object-oriented design, domain modeling, encapsulation/immutability, and extensible pricing/discount strategies within the Software Engineering Fundamentals domain at a component-level/class-interface design abstraction.

|Home/Software Engineering Fundamentals/Envoy
Envoy logo
Envoy
Mar 11, 2026, 12:00 AM
easySoftware EngineerTechnical ScreenSoftware Engineering Fundamentals
11
0

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.
Loading comments...