You’re working at Amazon retail and you’re in charge of implementing a method/function to be used by the promotions team to apply a discount to each individual item in the checkout cart.
The function is used to find items that meet a certain promotion criteria.
There are currently two ongoing promotions. The criteria for each promotion is as follows:
- Items in the cart that are a certain price (e.g. > $20).
- Items in the cart that belong to a certain product group. Product groups can be (Clothes, Hardware, Media, Toy, Food).
Given this information:
- Design the Cart and Item classes.
- Create the method/function that will find the items for each of the use cases above.
This Amazon interview design question focuses on modeling a shopping cart promotion system. You need to design Cart and Item classes, then implement a function that can filter items by promotion rules such as price thresholds and product groups. A clean solution typically stores item attributes like price and category in Item, keeps the item collection in Cart, and exposes a reusable filtering method. The main evaluation points are object-oriented design, clean separation of responsibilities, and extensibility for future promotion rules.