Skip to content

Commit 26f3524

Browse files
Preparing for Desert Code Camp
1 parent 25ec0cb commit 26f3524

File tree

10 files changed

+337
-334
lines changed

10 files changed

+337
-334
lines changed

AbstractFactory/RecipeFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public override Dessert CreateDessert()
5555
/// <summary>
5656
/// A concrete product
5757
/// </summary>
58-
class GrilledCheese : Sandwich { }
58+
class PBandJ : Sandwich { }
5959

6060
/// <summary>
6161
/// A concrete product
@@ -69,7 +69,7 @@ class KidCuisineFactory : RecipeFactory
6969
{
7070
public override Sandwich CreateSandwich()
7171
{
72-
return new GrilledCheese();
72+
return new PBandJ();
7373
}
7474

7575
public override Dessert CreateDessert()

Adapter/Program.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@ namespace Adapter
88
{
99
class Program
1010
{
11-
static void Main(string[] args)
12-
{
13-
//Non-adapted
14-
Meat unknown = new Meat("Beef");
15-
unknown.LoadData();
11+
static void Main(string[] args)
12+
{
13+
//Non-adapted
14+
Meat unknown = new Meat("Beef");
15+
unknown.LoadData();
1616

17-
//Adapted
18-
MeatDetails beef = new MeatDetails("Beef");
19-
beef.LoadData();
17+
//Adapted
18+
MeatDetails beef = new MeatDetails("Beef");
19+
beef.LoadData();
2020

21-
MeatDetails turkey = new MeatDetails("Turkey");
22-
turkey.LoadData();
21+
MeatDetails turkey = new MeatDetails("Turkey");
22+
turkey.LoadData();
2323

24-
MeatDetails chicken = new MeatDetails("Chicken");
25-
chicken.LoadData();
24+
MeatDetails chicken = new MeatDetails("Chicken");
25+
chicken.LoadData();
2626

27-
Console.ReadKey();
28-
}
27+
Console.ReadKey();
28+
}
2929
}
3030
}

Composite/Drinks.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace Composite
88
{
99
/// <summary>
10-
/// Leaf abstract class
10+
/// Component abstract class
1111
/// </summary>
1212
public abstract class SoftDrink
1313
{
@@ -86,7 +86,7 @@ public RootBeers()
8686
}
8787

8888
/// <summary>
89-
/// The Component class
89+
/// The Client class
9090
/// </summary>
9191
public class SodaDispenser
9292
{

Facade/Program.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,29 @@ namespace Facade
88
{
99
class Program
1010
{
11-
static void Main(string[] args)
12-
{
13-
Server server = new Server();
11+
static void Main(string[] args)
12+
{
13+
Server server = new Server();
1414

15-
Console.WriteLine("Hello! I'll be your server today. What is your name?");
16-
var name = Console.ReadLine();
15+
Console.WriteLine("Hello! I'll be your server today. What is your name?");
16+
var name = Console.ReadLine();
1717

18-
Patron patron = new Patron(name);
18+
Patron patron = new Patron(name);
1919

20-
Console.WriteLine("Hello " + patron.Name + ". What appetizer would you like? (1-15):");
21-
var appID = int.Parse(Console.ReadLine());
20+
Console.WriteLine("Hello " + patron.Name + ". What appetizer would you like? (1-15):");
21+
var appID = int.Parse(Console.ReadLine());
2222

23-
Console.WriteLine("That's a good one. What entree would you like? (1-20):");
24-
var entreeID = int.Parse(Console.ReadLine());
23+
Console.WriteLine("That's a good one. What entree would you like? (1-20):");
24+
var entreeID = int.Parse(Console.ReadLine());
2525

26-
Console.WriteLine("A great choice! Finally, what drink would you like? (1-60):");
27-
var drinkID = int.Parse(Console.ReadLine());
26+
Console.WriteLine("A great choice! Finally, what drink would you like? (1-60):");
27+
var drinkID = int.Parse(Console.ReadLine());
2828

29-
Console.WriteLine("I'll get that order in right away.");
29+
Console.WriteLine("I'll get that order in right away.");
3030

31-
server.PlaceOrder(patron, appID, entreeID, drinkID);
31+
server.PlaceOrder(patron, appID, entreeID, drinkID);
3232

33-
Console.ReadKey();
34-
}
33+
Console.ReadKey();
34+
}
3535
}
3636
}

Facade/Restaurant.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class ColdPrep : KitchenSection
5555
{
5656
public FoodItem PrepDish(int dishID)
5757
{
58+
Console.WriteLine("Cold Prep is preparing Appetizer #" + dishID);
5859
//Go prep the appetizer
5960
return new FoodItem()
6061
{
@@ -70,6 +71,7 @@ class HotPrep : KitchenSection
7071
{
7172
public FoodItem PrepDish(int dishID)
7273
{
74+
Console.WriteLine("Hot Prep is preparing Entree #" + dishID);
7375
//Go prep the entree
7476
return new FoodItem()
7577
{
@@ -85,6 +87,7 @@ class Bar : KitchenSection
8587
{
8688
public FoodItem PrepDish(int dishID)
8789
{
90+
Console.WriteLine("The Bar is preparing Drink #" + dishID);
8891
//Go mix the drink
8992
return new FoodItem()
9093
{

FactoryMethodPattern/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ static void Main(string[] args)
1717
foreach(var sandwich in sandwiches)
1818
{
1919
Console.WriteLine("\nSandwich: " + sandwich.GetType().Name + " ");
20-
foreach(var weapon in sandwich.Ingredients)
20+
foreach(var ingredient in sandwich.Ingredients)
2121
{
22-
Console.WriteLine("Ingredient: " + weapon.GetType().Name);
22+
Console.WriteLine("Ingredient: " + ingredient.GetType().Name);
2323
}
2424
}
2525

Observer/Program.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ namespace Observer
88
{
99
class Program
1010
{
11-
static void Main(string[] args)
12-
{
13-
// Create price watch for Carrots and attach restaurants that buy carrots from suppliers.
14-
Carrots carrots = new Carrots(0.82);
15-
carrots.Attach(new Restaurant("Mackay's", 0.77));
16-
carrots.Attach(new Restaurant("Johnny's Sports Bar", 0.74));
17-
carrots.Attach(new Restaurant("Salad Kingdom", 0.75));
11+
static void Main(string[] args)
12+
{
13+
// Create price watch for Carrots and attach restaurants that buy carrots from suppliers.
14+
Carrots carrots = new Carrots(0.82);
15+
carrots.Attach(new Restaurant("Mackay's", 0.77));
16+
carrots.Attach(new Restaurant("Johnny's Sports Bar", 0.74));
17+
carrots.Attach(new Restaurant("Salad Kingdom", 0.75));
1818

19-
// Fluctuating carrot prices will notify subscribing restaurants.
20-
carrots.PricePerPound = 0.79;
21-
carrots.PricePerPound = 0.76;
22-
carrots.PricePerPound = 0.74;
23-
carrots.PricePerPound = 0.81;
19+
// Fluctuating carrot prices will notify subscribing restaurants.
20+
carrots.PricePerPound = 0.79;
21+
carrots.PricePerPound = 0.76;
22+
carrots.PricePerPound = 0.74;
23+
carrots.PricePerPound = 0.81;
2424

25-
Console.ReadKey();
26-
}
25+
Console.ReadKey();
26+
}
2727
}
2828
}

Prototype/Program.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,28 @@
66

77
namespace Prototype
88
{
9-
class Program
10-
{
11-
static void Main(string[] args)
9+
class Program
1210
{
13-
SandwichMenu sandwichMenu = new SandwichMenu();
11+
static void Main(string[] args)
12+
{
13+
SandwichMenu sandwichMenu = new SandwichMenu();
1414

15-
// Initialize with default sandwiches
16-
sandwichMenu["BLT"] = new Sandwich("Wheat", "Bacon", "", "Lettuce, Tomato");
17-
sandwichMenu["PB&J"] = new Sandwich("White", "", "", "Peanut Butter, Jelly");
18-
sandwichMenu["Turkey"] = new Sandwich("Rye", "Turkey", "Swiss", "Lettuce, Onion, Tomato");
15+
// Initialize with default sandwiches
16+
sandwichMenu["BLT"] = new Sandwich("Wheat", "Bacon", "", "Lettuce, Tomato");
17+
sandwichMenu["PB&J"] = new Sandwich("White", "", "", "Peanut Butter, Jelly");
18+
sandwichMenu["Turkey"] = new Sandwich("Rye", "Turkey", "Swiss", "Lettuce, Onion, Tomato");
1919

20-
// Deli manager adds custom sandwiches
21-
sandwichMenu["LoadedBLT"] = new Sandwich("Wheat", "Turkey, Bacon", "American", "Lettuce, Tomato, Onion, Olives");
22-
sandwichMenu["ThreeMeatCombo"] = new Sandwich("Rye", "Turkey, Ham, Salami", "Provolone", "Lettuce, Onion");
23-
sandwichMenu["Vegetarian"] = new Sandwich("Wheat", "", "", "Lettuce, Onion, Tomato, Olives, Spinach");
20+
// Deli manager adds custom sandwiches
21+
sandwichMenu["LoadedBLT"] = new Sandwich("Wheat", "Turkey, Bacon", "American", "Lettuce, Tomato, Onion, Olives");
22+
sandwichMenu["ThreeMeatCombo"] = new Sandwich("Rye", "Turkey, Ham, Salami", "Provolone", "Lettuce, Onion");
23+
sandwichMenu["Vegetarian"] = new Sandwich("Wheat", "", "", "Lettuce, Onion, Tomato, Olives, Spinach");
2424

25-
// Now we can clone the sandwiches.
26-
Sandwich sandwich1 = sandwichMenu["BLT"].Clone() as Sandwich;
27-
Sandwich sandwich2 = sandwichMenu["ThreeMeatCombo"].Clone() as Sandwich;
28-
Sandwich sandwich3 = sandwichMenu["Vegetarian"].Clone() as Sandwich;
25+
// Now we can clone the sandwiches.
26+
Sandwich sandwich1 = sandwichMenu["BLT"].Clone() as Sandwich;
27+
Sandwich sandwich2 = sandwichMenu["ThreeMeatCombo"].Clone() as Sandwich;
28+
Sandwich sandwich3 = sandwichMenu["Vegetarian"].Clone() as Sandwich;
2929

30-
Console.ReadKey();
30+
Console.ReadKey();
31+
}
3132
}
3233
}
33-
}

0 commit comments

Comments
 (0)