-
Notifications
You must be signed in to change notification settings - Fork 629
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
gowtkum
committed
Jul 13, 2021
1 parent
9c2d854
commit 8c2bc76
Showing
52 changed files
with
852 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> |
Binary file added
BIN
+393 Bytes
FoodKart/out/production/FoodKart/Exceptions/RestaurantAlreadyPresent.class
Binary file not shown.
Binary file added
BIN
+381 Bytes
FoodKart/out/production/FoodKart/Exceptions/RestaurantNotPresent.class
Binary file not shown.
Binary file added
BIN
+375 Bytes
FoodKart/out/production/FoodKart/Exceptions/UserAlreadyPresent.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+512 Bytes
FoodKart/out/production/FoodKart/service/FoodKartRestaurantService.class
Binary file not shown.
Binary file added
BIN
+2.61 KB
FoodKart/out/production/FoodKart/service/FoodKartRestaurantServiceImpl.class
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+1.46 KB
FoodKart/out/production/FoodKart/service/FoodKartUserServiceImpl.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+324 Bytes
FoodKart/out/production/FoodKart/strategy/RestaurantDisplayStrategy.class
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
Foodkart: | ||
|
||
Description: | ||
|
||
Flipkart is starting a new online food ordering service. In this Service, users can order food from a restaurant which is serviceable in their area and the restaurant will deliver it. | ||
Features: | ||
|
||
Restaurants can only serve one specialized dish. | ||
Restaurants can serve in multiple areas. | ||
At a time, users can order from one restaurant, and the quantity of food can be more than one. | ||
Users should be able to rate any restaurant with or without comment. | ||
Rating of a restaurant is the average rating given by all customers. | ||
Requirements: | ||
|
||
Register a User: | ||
register_user(user_details) | ||
|
||
user_details: name, gender, phoneNumber(unique) and pincode. | ||
|
||
Users should be able to login, and all the operations will happen in the context of that user. If another user logged in, the previous user will automatically be logged out. | ||
login_user(user_id): this should set the context for all the next operation to be done by this user. | ||
Register a restaurant in context of login user: | ||
Register_restaurant(resturant_name, list of serviceable pin-codes, food item name, food item price, initial quantity). | ||
Restaurant owners should be able to increase the quantity of the food item. | ||
update_quantity(restaurant name, quantity to Add) | ||
Users should be able to rate(1(Lowest)-5(Highest)) any restaurant with or without comment. | ||
rate_restaurant(restaurant name, rating, comment) | ||
User should be able to get list of all serviceable restaurant, food item name and price in descending order: show_restaurant(rating/price) | ||
Based on rating | ||
Based on Price | ||
NOTE: A restaurant is serviceable when it delivers to the user's pincode and has non-zero quantity of food item. | ||
Place an order from any restaurant with any allowed quantity. | ||
place_order(restaurant name, quantity) | ||
Bonus: | ||
Order History of User: For a given user you should be able to fetch order history. | ||
Other Details: | ||
Do not use any database or NoSQL store, use in-memory store for now. | ||
Do not create any UI for the application. | ||
Write a driver class for demo purposes. Which will execute all the commands at one place in the code and test cases. | ||
Please prioritize code compilation, execution and completion. | ||
Please do not access the internet for anything EXCEPT syntax. | ||
You are free to use the language of your choice. | ||
All work should be your own. If found otherwise, you may be disqualified. | ||
Expectations: | ||
Code should be demoable (very important) | ||
Complete coding within the duration of 90 minutes. | ||
Code should be modular, with Object Oriented design. Maintain good separation of concerns. | ||
Code should be extensible. It should be easy to add/remove functionality without rewriting the entire codebase. | ||
Code should handle edge cases properly and fail gracefully. | ||
Code should be readable. Follow good coding practices: | ||
Use intuitive variable names, function names, class names etc. | ||
Indent code properly. | ||
Once the code is complete please zip the source code and upload it to: https://docs.google.com/forms/d/e/1FAIpQLSfzz8HH6fLso7NLgqJ0kC0TYP-tZhC2XhTN4EdI2c6OC1v2XA/viewform | ||
Sample Test Case: | ||
All the inputs here are just indicating the high level inputs that function should accept. You are free to model entities as per your choice. | ||
|
||
register_user(“Pralove”, “M”, “phoneNumber-1”, “HSR”) | ||
register_user(“Nitesh”, “M”, “phoneNumber-2”, “BTM”) | ||
register_user(“Vatsal”, “M”, “phoneNumber-3”, “BTM”) | ||
|
||
login_user(“phoneNumber-1”) | ||
|
||
register_restaurant(“Food Court-1”, “BTM/HSR”, “NI Thali”, 100, 5) | ||
NOTE: we will have 2 delimiters in input : ',' to specify separate fields & '/' to identify different pincodes. | ||
register_restaurant(“Food Court-2”, “BTM”, “Burger”, 120, 3) | ||
|
||
login_user(“phoneNumber-2”) | ||
register_restaurant(“Food Court-3”, “HSR”, “SI Thali”, 150, 1) | ||
login_user(“phoneNumber-3”) | ||
show_restaurant(“price”) | ||
|
||
Output : Food Court-2, Burger | ||
Food Court-1, NI Thali | ||
|
||
place_order(“Food Court-1”, 2) | ||
Output: Order Placed Successfully. | ||
|
||
place_order(““Food Court-2”, 7) | ||
Output : Cannot place order | ||
|
||
create_review(“Food Court-2”, 3, “Good Food”) | ||
create_review(“Food Court-1”, 5, “Nice Food”) | ||
|
||
show_restaurant(“rating”) | ||
Output : Food Court-1, NI Thali | ||
Food Court-2, Burger | ||
|
||
login_user(“phoneNumber-1”) | ||
update_quantity(“Food Court-2”, 5) | ||
Output: Food Court-2, BTM, Burger - 8 | ||
|
||
update_location(“Food Court-2”, “BTM/HSR”) | ||
Output: Food Court-2, “BTM/HSR”, Burger - 8 | ||
|
||
|
||
|
||
https://docs.google.com/document/d/1Bmkz9omByHqVvwU45cvkBRSwJAPKw9yaDsRlEnCg_lg/edit# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package Exceptions; | ||
|
||
public class RestaurantAlreadyPresent extends RuntimeException { | ||
public RestaurantAlreadyPresent(String message) { | ||
super(message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package Exceptions; | ||
|
||
public class RestaurantNotPresent extends RuntimeException { | ||
public RestaurantNotPresent(String message) { | ||
super(message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package Exceptions; | ||
|
||
public class UserAlreadyPresent extends RuntimeException { | ||
public UserAlreadyPresent(String message) { | ||
super(message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package Exceptions; | ||
|
||
public class UserNotPresent extends RuntimeException{ | ||
public UserNotPresent(String message) { | ||
super(message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import model.Restaurant; | ||
import service.FoodKartRestaurantService; | ||
import service.FoodKartRestaurantServiceImpl; | ||
import service.FoodKartUserService; | ||
import service.FoodKartUserServiceImpl; | ||
|
||
import java.util.List; | ||
|
||
public class FoodKartApplication { | ||
public static void main(String[] args) { | ||
FoodKartUserService userService = new FoodKartUserServiceImpl(); | ||
FoodKartRestaurantService restaurantService = new FoodKartRestaurantServiceImpl(); | ||
|
||
userService.registerUser("Pralove", "Male", "phoneNumber-1", "HSR"); | ||
userService.registerUser("Nitesh", "Male", "phoneNumber-2", "BTM"); | ||
userService.registerUser("Vatsal", "female", "phoneNumber-3", "BTM"); | ||
|
||
// login user | ||
userService.loginUser("phoneNumber-1"); | ||
|
||
// register restaurant | ||
restaurantService.registerRestaurant("Food Court-1", "BTM/HSR", "NI Thali", 100, 5); | ||
restaurantService.registerRestaurant("Food Court-2", "BTM", "Burger", 120, 3); | ||
restaurantService.registerRestaurant("Food Court-3", "HSR", "SI Thali", 150, 1); | ||
|
||
userService.loginUser("phoneNumber-3"); | ||
List<Restaurant> list = restaurantService.showRestaurant("price"); | ||
for (Restaurant restaurant : list) { | ||
System.out.println(restaurant.getRestaurantName() + " " + restaurant.getFoodItem().getName()); | ||
} | ||
|
||
if(restaurantService.placeOrder("Food Court-1", 2)){ | ||
System.out.println("Order Placed Successfully"); | ||
} | ||
|
||
if(!restaurantService.placeOrder("Food Court-2", 7)){ | ||
System.out.println("Cannot place order"); | ||
} | ||
|
||
|
||
restaurantService.rateRestaurant("Food Court-2", 3, "Good Food"); | ||
restaurantService.rateRestaurant("Food Court-1", 5, "Nice Food"); | ||
|
||
list = restaurantService.showRestaurant("rating"); | ||
for (Restaurant restaurant : list) { | ||
System.out.println(restaurant.getRestaurantName() + " " + restaurant.getFoodItem().getName()); | ||
} | ||
|
||
userService.loginUser("phoneNumber-1"); | ||
restaurantService.updateQuantity("Food Court-2",5); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package Util; | ||
|
||
import model.Restaurant; | ||
import model.User; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
public class FoodKartUtil { | ||
public static List<Restaurant> getMatchingRestaurant(List<Restaurant> listOfRestaurants, User currentUser) { | ||
List<Restaurant> list = new ArrayList<>(listOfRestaurants); | ||
Iterator iterator = list.iterator(); | ||
while (iterator.hasNext()) { | ||
Restaurant restaurant = (Restaurant) iterator.next(); | ||
if (!restaurant.isLocationServiceAble(currentUser.getPincode()) && restaurant.isEnoughQuantityAvailable()) { | ||
iterator.remove(); | ||
} | ||
} | ||
return list; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package dao; | ||
|
||
import model.Order; | ||
|
||
import java.util.HashMap; | ||
|
||
public class OrderDao { | ||
HashMap<Integer, Order> listOfOrders; | ||
HashMap<String, Order> userOrderMap; | ||
} |
Oops, something went wrong.