Design a Wishlist and Cart System with Discounts
Problem
Design an OOP model for Myntra's wishlist, cart, and checkout system with a flexible discount/coupon engine.
Requirements
addToWishlist(userId, productId)/moveToCart(userId, productId)applyDiscount(cartId, couponCode)→ validates and appliesgetCartTotal(cartId)— returns itemised + discounted totalcheckout(cartId, paymentMethod)→ reserves inventory and creates order- Multiple discount types: flat, percentage, BOGO, minimum cart value
Key classes
Wishlist, Cart, CartItem, DiscountRule, DiscountEngine, Order
Patterns
- Strategy for different discount types
- Decorator for stacking multiple discounts
- Template Method for checkout flow steps
Extension
Add "save for later" — moves item from cart to a saved list without deleting.
added …