Skip to content

Commit 4e14d68

Browse files
author
gmershad
committed
changes
1 parent 27be94a commit 4e14d68

13 files changed

+106
-48
lines changed

FoodDeliveryApp.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
<Compile Include="FoodBuilding\MealBuilder.cs" />
4848
<Compile Include="FoodDeliveryAppModel\UserModel.cs" />
4949
<Compile Include="FoodDeliveryDriver\MealBuilderDriver.cs" />
50+
<Compile Include="FoodDeliveryDriver\MealMenuIteratorDriver.cs" />
5051
<Compile Include="FoodDeliveryDriver\MealOrderDriver.cs" />
5152
<Compile Include="FoodDeliveryDriver\MealSelectorDriver.cs" />
5253
<Compile Include="FoodDeliveryDriver\OrderTrackingDriver.cs" />
@@ -66,7 +67,7 @@
6667
<Compile Include="RestaurantSearch\AbstractExpression.cs" />
6768
<Compile Include="RestaurantSearch\RestaurantLocationExpression.cs" />
6869
<Compile Include="RestaurantSearch\RestaurantSearchClient.cs" />
69-
<Compile Include="RestaurantSearch\RestaurantSearchDriver.cs" />
70+
<Compile Include="FoodDeliveryDriver\RestaurantSearchDriver.cs" />
7071
<Compile Include="RestaurantWebService\FoodMenuService.cs" />
7172
<Compile Include="RestaurantWebService\RestaurantService.cs" />
7273
<Compile Include="Tracking\Customers.cs" />

FoodDeliveryApp.v12.suo

4.5 KB
Binary file not shown.

FoodDeliveryDriver/MealBuilderDriver.cs

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ namespace FoodDeliveryApp.FoodDeliveryDriver
1010
{
1111
public class MealBuilderDriver
1212
{
13+
/// <summary>
14+
/// This driver called that module which followed Builder Design Pattern
15+
/// </summary>
16+
/// <param name="selectedMealItems"></param>
17+
/// <returns></returns>
1318
public double BuildMealForUser(List<FoodMenuModel> selectedMealItems)
1419
{
1520
Console.WriteLine();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using FoodDeliveryApp.FoodDeliveryAppModel;
2+
using FoodDeliveryApp.RestaurantFoodMenu;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace FoodDeliveryApp.FoodDeliveryDriver
10+
{
11+
/// <summary>
12+
/// This driver called - Iterator Pattern.
13+
/// </summary>
14+
public class MealMenuIteratorDriver
15+
{
16+
public List<FoodMenuModel> PrintMealMenu(string restaurantId)
17+
{
18+
Waitress waitress = new Waitress(restaurantId);
19+
var foodMenu = waitress.PrintFoodMenu();
20+
return foodMenu;
21+
}
22+
}
23+
}

FoodDeliveryDriver/MealOrderDriver.cs

+9
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ namespace FoodDeliveryApp.FoodDeliveryDriver
1010
{
1111
public class MealOrderDriver
1212
{
13+
/// <summary>
14+
/// This driver called Command Design Pattern
15+
/// </summary>
16+
/// <param name="selectedMealItems"></param>
17+
/// <param name="totalCost"></param>
18+
/// <param name="restaurantId"></param>
19+
/// <param name="orderId"></param>
20+
/// <param name="user"></param>
21+
/// <returns></returns>
1322
public char MealOrderByUser(List<FoodMenuModel> selectedMealItems, double totalCost, string restaurantId, out string orderId, out UserModel user)
1423
{
1524
Console.WriteLine(string.Empty);

FoodDeliveryDriver/OrderTrackingDriver.cs

+7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ namespace FoodDeliveryApp.FoodDeliveryDriver
1111
{
1212
public class OrderTrackingDriver
1313
{
14+
/// <summary>
15+
/// This Driver used Observer Design Pattern
16+
/// </summary>
17+
/// <param name="restaurantId"></param>
18+
/// <param name="orderId"></param>
19+
/// <param name="user"></param>
20+
/// <param name="cancel"></param>
1421
public void OrderTrackingByUser(string restaurantId, string orderId, UserModel user, char cancel)
1522
{
1623
//Order Tracking.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace FoodDeliveryApp.RestaurantSearch
8+
{
9+
10+
/// <summary>
11+
/// This driver called module developed in Interpreter design pattern
12+
/// </summary>
13+
public class RestaurantSearchDriver
14+
{
15+
public string RestaurantSearch()
16+
{
17+
InterpreterContext context = new InterpreterContext("Some API");
18+
RestaurantSearchClient client = new RestaurantSearchClient(context);
19+
Console.WriteLine("Search Restaurant(by Location)");
20+
Console.WriteLine("Enter Location:");
21+
var location = Console.ReadLine();
22+
string searchSentence = string.Format("restaurant by location '{0}'", location);
23+
var result = client.Intercept(searchSentence);
24+
if (!result.Any()) Console.WriteLine("Sorry, No Restaurants available in this location.");
25+
26+
string restaurantId = string.Empty;
27+
28+
if (result.Any())
29+
{
30+
Console.WriteLine("List of Restaurants");
31+
Console.WriteLine("*******************");
32+
33+
foreach (var item in result)
34+
{
35+
Console.WriteLine(" ");
36+
Console.WriteLine("{0} {1}", item.RestaurantId, item.Name);
37+
Console.WriteLine("{0}", item.Address);
38+
int rating = item.Rating;
39+
Console.Write("Rating: ");
40+
while (rating > 0)
41+
{
42+
Console.Write("*");
43+
rating--;
44+
}
45+
46+
Console.WriteLine("");
47+
Console.WriteLine("_________________________________");
48+
}
49+
50+
Console.WriteLine();
51+
Console.WriteLine("Please Select Restaurant by Id: ");
52+
restaurantId = Console.ReadLine();
53+
}
54+
55+
return restaurantId;
56+
}
57+
}
58+
}

Program.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ static void Main(string[] args)
3030
#region User Sees Food Menu
3131

3232
//User sees Food Menu Items based on the selected Restaurant Id.
33-
Waitress waitress = new Waitress(restaurantId);
34-
var foodMenu = waitress.PrintFoodMenu();
33+
MealMenuIteratorDriver mealMenuIteratorDriver = new MealMenuIteratorDriver();
34+
var foodMenu = mealMenuIteratorDriver.PrintMealMenu(restaurantId);
3535

3636
#endregion
3737

RestaurantSearch/RestaurantSearchDriver.cs

-45
This file was deleted.

bin/Debug/FoodDeliveryApp.exe

0 Bytes
Binary file not shown.

bin/Debug/FoodDeliveryApp.pdb

4 KB
Binary file not shown.

obj/Debug/FoodDeliveryApp.exe

0 Bytes
Binary file not shown.

obj/Debug/FoodDeliveryApp.pdb

4 KB
Binary file not shown.

0 commit comments

Comments
 (0)