Skip to content

Commit 3abff1d

Browse files
Updating lots of names and comments.
1 parent c7b2f1a commit 3abff1d

File tree

20 files changed

+568
-555
lines changed

20 files changed

+568
-555
lines changed

AbstractFactory/Program.cs

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

77
namespace AbstractFactory
88
{
9-
class Program
9+
class Program
10+
{
11+
/// <summary>
12+
/// The Abstract Factory pattern provides an interface for creating related families of objects
13+
/// without needing to specify the concrete implementations. This pattern is critical for ideas
14+
/// like Dependency Injection.
15+
/// </summary>
16+
/// <param name="args"></param>
17+
static void Main(string[] args)
1018
{
11-
/// <summary>
12-
/// The Abstract Factory pattern provides an interface for creating related families of objects
13-
/// without needing to specify the concrete implementations. This pattern is critical for ideas
14-
/// like Dependency Injection.
15-
/// </summary>
16-
/// <param name="args"></param>
17-
static void Main(string[] args)
19+
Console.WriteLine("Who are you? (A)dult or (C)hild?");
20+
char input = Console.ReadKey().KeyChar;
21+
RecipeFactory factory;
22+
switch(input)
1823
{
19-
Console.WriteLine("Who are you? (A)dult or (C)hild?");
20-
char input = Console.ReadKey().KeyChar;
21-
RecipeFactory factory;
22-
switch(input)
23-
{
24-
case 'A':
25-
factory = new AdultCuisineFactory();
26-
break;
24+
case 'A':
25+
factory = new AdultCuisineFactory();
26+
break;
2727

28-
case 'C':
29-
factory = new KidCuisineFactory();
30-
break;
28+
case 'C':
29+
factory = new KidCuisineFactory();
30+
break;
3131

32-
default:
33-
throw new NotImplementedException();
32+
default:
33+
throw new NotImplementedException();
3434

35-
}
35+
}
3636

37-
var sandwich = factory.CreateSandwich();
38-
var dessert = factory.CreateDessert();
37+
var sandwich = factory.CreateSandwich();
38+
var dessert = factory.CreateDessert();
3939

40-
Console.WriteLine("\nSandwich: " + sandwich.GetType().Name);
41-
Console.WriteLine("Dessert: " + dessert.GetType().Name);
40+
Console.WriteLine("\nSandwich: " + sandwich.GetType().Name);
41+
Console.WriteLine("Dessert: " + dessert.GetType().Name);
4242

43-
Console.ReadKey();
44-
}
43+
Console.ReadKey();
4544
}
4645
}
46+
}

AbstractFactory/RecipeFactory.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ namespace AbstractFactory
1111
/// </summary>
1212
abstract class Sandwich { }
1313

14-
/// <summary>
15-
/// An abstract object.
16-
/// </summary>
17-
abstract class Roast { }
18-
1914
/// <summary>
2015
/// An abstract object.
2116
/// </summary>

Adapter/Meats.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,21 @@ public double GetProteinPerOunce(string meat)
8484
/// </summary>
8585
class Meat
8686
{
87-
protected string _meatName;
88-
protected float _safeCookTempFahrenheit;
89-
protected float _safeCookTempCelsius;
90-
protected double _caloriesPerOunce;
91-
protected double _proteinPerOunce;
87+
protected string MeatName;
88+
protected float SafeCookTempFahrenheit;
89+
protected float SafeCookTempCelsius;
90+
protected double CaloriesPerOunce;
91+
protected double ProteinPerOunce;
9292

9393
// Constructor
9494
public Meat(string meat)
9595
{
96-
this._meatName = meat;
96+
this.MeatName = meat;
9797
}
9898

99-
public virtual void Display()
99+
public virtual void LoadData()
100100
{
101-
Console.WriteLine("\nMeat: {0} ------ ", _meatName);
101+
Console.WriteLine("\nMeat: {0} ------ ", MeatName);
102102
}
103103
}
104104

@@ -107,29 +107,29 @@ public virtual void Display()
107107
/// </summary>
108108
class MeatDetails : Meat
109109
{
110-
private MeatDatabase _bank;
110+
private MeatDatabase _meatDatabase;
111111

112112
// Constructor
113113
public MeatDetails(string name)
114114
: base(name)
115115
{
116116
}
117117

118-
public override void Display()
118+
public override void LoadData()
119119
{
120120
// The Adaptee
121-
_bank = new MeatDatabase();
121+
_meatDatabase = new MeatDatabase();
122122

123-
_safeCookTempFahrenheit = _bank.GetSafeCookTemp(_meatName, TemperatureType.Fahrenheit);
124-
_safeCookTempCelsius = _bank.GetSafeCookTemp(_meatName, TemperatureType.Celsius);
125-
_caloriesPerOunce = _bank.GetCaloriesPerOunce(_meatName);
126-
_proteinPerOunce = _bank.GetProteinPerOunce(_meatName);
123+
SafeCookTempFahrenheit = _meatDatabase.GetSafeCookTemp(MeatName, TemperatureType.Fahrenheit);
124+
SafeCookTempCelsius = _meatDatabase.GetSafeCookTemp(MeatName, TemperatureType.Celsius);
125+
CaloriesPerOunce = _meatDatabase.GetCaloriesPerOunce(MeatName);
126+
ProteinPerOunce = _meatDatabase.GetProteinPerOunce(MeatName);
127127

128-
base.Display();
129-
Console.WriteLine(" Safe Cook Temp (F): {0}", _safeCookTempFahrenheit);
130-
Console.WriteLine(" Safe Cook Temp (C): {0}", _safeCookTempCelsius);
131-
Console.WriteLine(" Calories per Ounce: {0}", _caloriesPerOunce);
132-
Console.WriteLine(" Protein per Ounce: {0}", _proteinPerOunce);
128+
base.LoadData();
129+
Console.WriteLine(" Safe Cook Temp (F): {0}", SafeCookTempFahrenheit);
130+
Console.WriteLine(" Safe Cook Temp (C): {0}", SafeCookTempCelsius);
131+
Console.WriteLine(" Calories per Ounce: {0}", CaloriesPerOunce);
132+
Console.WriteLine(" Protein per Ounce: {0}", ProteinPerOunce);
133133
}
134134
}
135135
}

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.Display();
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.Display();
17+
//Adapted
18+
MeatDetails beef = new MeatDetails("Beef");
19+
beef.LoadData();
2020

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

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

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

Bridge/OrderingSystem.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ public abstract class SendOrder
2525
public abstract void Send();
2626
}
2727

28-
/// <summary>
29-
/// Refined abstraction for a vegetarian order
30-
/// </summary>
31-
public class SendVegetarianOrder : SendOrder
28+
/// <summary>
29+
/// Refined abstraction for a dairy-free order
30+
/// </summary>
31+
public class SendDairyFreeOrder : SendOrder
32+
{
33+
public override void Send()
3234
{
33-
public override void Send()
34-
{
35-
_restaurant.Place("Vegetarian Order");
36-
}
35+
_restaurant.Place("Dairy-Free Order");
3736
}
37+
}
3838

3939
/// <summary>
4040
/// Refined abstraction for a gluten free order

Bridge/Program.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@ namespace Bridge
88
{
99
class Program
1010
{
11-
static void Main(string[] args)
12-
{
13-
SendOrder _sendOrder = new SendVegetarianOrder();
14-
_sendOrder._restaurant = new DinerOrders();
15-
_sendOrder.Send();
11+
static void Main(string[] args)
12+
{
13+
SendOrder _sendOrder = new SendDairyFreeOrder();
14+
_sendOrder._restaurant = new DinerOrders();
15+
_sendOrder.Send();
1616

17-
_sendOrder._restaurant = new FancyRestaurantOrders();
18-
_sendOrder.Send();
17+
_sendOrder._restaurant = new FancyRestaurantOrders();
18+
_sendOrder.Send();
1919

20-
_sendOrder = new SendGlutenFreeOrder();
21-
_sendOrder._restaurant = new DinerOrders();
22-
_sendOrder.Send();
20+
_sendOrder = new SendGlutenFreeOrder();
21+
_sendOrder._restaurant = new DinerOrders();
22+
_sendOrder.Send();
2323

24-
_sendOrder._restaurant = new FancyRestaurantOrders();
25-
_sendOrder.Send();
24+
_sendOrder._restaurant = new FancyRestaurantOrders();
25+
_sendOrder.Send();
2626

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

Builder/Program.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,28 @@ namespace Builder
88
{
99
class Program
1010
{
11-
static void Main(string[] args)
12-
{
13-
SandwichBuilder builder;
11+
static void Main(string[] args)
12+
{
13+
SandwichBuilder builder;
1414

15-
// Create shop with vehicle builders
16-
AssemblyLine shop = new AssemblyLine();
15+
// Create deli with sandwich assembly line
16+
AssemblyLine shop = new AssemblyLine();
1717

18-
// Construct and display vehicles
19-
builder = new HamAndCheese();
20-
shop.Assemble(builder);
21-
builder.Vehicle.Show();
18+
// Construct and display sandwiches
19+
builder = new HamAndCheese();
20+
shop.Assemble(builder);
21+
builder.Sandwich.Show();
2222

23-
builder = new BLT();
24-
shop.Assemble(builder);
25-
builder.Vehicle.Show();
23+
builder = new BLT();
24+
shop.Assemble(builder);
25+
builder.Sandwich.Show();
2626

27-
builder = new TurkeyClub();
28-
shop.Assemble(builder);
29-
builder.Vehicle.Show();
27+
builder = new TurkeyClub();
28+
shop.Assemble(builder);
29+
builder.Sandwich.Show();
3030

31-
// Wait for user
32-
Console.ReadKey();
33-
}
31+
// Wait for user
32+
Console.ReadKey();
33+
}
3434
}
3535
}

0 commit comments

Comments
 (0)