Flipkart Daily.
Description:
Flipkart wants to build a product to deliver groceries and daily essentials by next morning. Users can search for items from inventory with some filters and will be allowed to place an order only if He/She has enough amount in the wallet.
Features:
1. Define price for the items. SetPrice(category, brand, price)
2. Add item to inventory. AddItem(category, brand, quantity)
(category → milk, bread & brand → Amul milk or Britannia bread)
3. Add/remove item to user’s cart.
- Get current user cart info.
- Checkout - This places the order directly using the wallet amount.
Bonus:
- Search items in inventory via using multiple filters like price, brand, category and can perform search with multiple filters.
search(brand,price), search(category, price), search(brand,category)...
Other Details:
- Do not use any database or NoSQL store, use in-memory store for now. 2. Do not create any UI for the application.
- Write a driver class for demo purpose. Which will execute all the commands at one place in the code and test cases.
- Start with min 5 items with more quantities varying from 0-30
- Assume that only one active session will be there for customers.
Expectations:
- Make sure that you can execute your code and show that it is working. 2. Make sure that code is functionally correct.
- Work on the expected output first and then add good-to-have features of your own. 4. Code should be modular and readable.
- Code should easily accommodate new requirements with minimal changes. 6. Code should be easily testable.
- Extendability of the code for implementing new features.
Test cases: (You need not follow the same method signatures and output) 1. Add/Update Item (brand, category, price)
- Add inventory (category,brand, quantity)
- Add user (“Name”,”Address”,”Wallet Amount”)
- Search (“brand”,”category”) - expected response <brand, category, price, remaining_inventory_count> {Bonus}
- Add to cart(user, category, brand, quantity) 6. Get cart info(user)
- Remove from cart {Bonus}
Sample input/output
AddItem(<item_brand>, <item_category>, <item_price>)
AddItem(Amul, Milk, 100)
AddItem(Amul, Curd, 50)
AddItem(Nestle, Milk, 60)
AddItem(Nestle, Curd, 90)
AddInventory(<item_brand>, <item_category>, )
AddInventory(Amul, Milk, 10)
AddInventory(Nestle, Milk, 15)
AddInventory(Nestle, Curd, 10)
AddInventory(Amul, Milk, 10)
AddInventory(Amul, Curd, 5)
Final View Inventory :
Amul - > Milk -> 20
Amul -> Curd -> 5
Nestle -> Milk -> 15
Nestle -> Curd -> 10
#AddUser(,
,)
AddUser(Jhonny, ”Flipkart Bellandur, Bangalore 560068”, 600)
AddUser(Naruto, ”BTM Layout, Bengaluru, 560042”, 500)
AddUser(Goku, ”Vijay Nagar, Indore, MP”, 3000)
AddToCart(<User_Name>, <item_category>, <item_brand>, )
AddToCart(Jhonny, Milk, Nestle, 5)
UpdateItem(Nestle, Milk, 5)
AddToCart(Goku, Milk, Nestle, 10)
GetCart(<User_Name>)
GetCart(Goku)
Nestle -> Milk - > 10 → Total Price 50
GetCart(Jhonny)
Nestle -> Milk -> 5 -> Total Price : 25 GetCart(Naruto)
Empty Cart
expected response <brand, category, price, remaining_inventory_count>
SearchItems([Nestle])
Nestle -> Curd-> 90 -> 10
SearchItems([Nestle, Amul], [Curd])
Amul -> Curd -> 50 -> 5
Nestle -> Curd -> 90 -> 10
SearchItems([Nestle], [Curd, Milk, Paneer]) Nestle -> Curd -> 90 -> 10
Nestle -> Milk -> 60 -> 0
Checkout()
Checkout(Goku)
-> Successful checkout , new wallet amount: 2950
Checkout(Jhonny)
-> Successful checkout , new wallet amount: 575
Checkout(Naruto)
-> No order to checkout
Note: in case the wallet amount is less than cart total amount, checkout fails
ALL THE BEST