├── .gitattributes
├── .gitignore
├── AbstractFactory
├── AbstractFactory.csproj
├── App.config
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
└── RecipeFactory.cs
├── Adapter
├── Adapter.csproj
├── App.config
├── Meats.cs
├── Program.cs
└── Properties
│ └── AssemblyInfo.cs
├── Bridge
├── App.config
├── Bridge.csproj
├── OrderingSystem.cs
├── Program.cs
└── Properties
│ └── AssemblyInfo.cs
├── Builder
├── App.config
├── Builder.csproj
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
└── SandwichAssemblyLine.cs
├── ChainOfResponsibility
├── App.config
├── ChainOfResponsibility.csproj
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
└── RestaurantRequest.cs
├── Command
├── App.config
├── Command.csproj
├── Ordering.cs
├── Program.cs
└── Properties
│ └── AssemblyInfo.cs
├── Composite
├── App.config
├── Composite.csproj
├── Drinks.cs
├── Program.cs
└── Properties
│ └── AssemblyInfo.cs
├── Decorator
├── App.config
├── Decorator.csproj
├── FarmFresh.cs
├── Program.cs
└── Properties
│ └── AssemblyInfo.cs
├── DesignPatterns.sln
├── Facade
├── App.config
├── Facade.csproj
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
└── Restaurant.cs
├── FactoryMethodPattern
├── App.config
├── FactoryMethod.csproj
├── Ingredients.cs
├── Program.cs
└── Properties
│ └── AssemblyInfo.cs
├── Flyweight
├── App.config
├── Flyweight.csproj
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
└── Sliders.cs
├── Interpreter
├── App.config
├── FoodLanguage.cs
├── Interpreter.csproj
├── Program.cs
└── Properties
│ └── AssemblyInfo.cs
├── Iterator
├── App.config
├── Iterator.csproj
├── JellyBeans.cs
├── Program.cs
└── Properties
│ └── AssemblyInfo.cs
├── Mediator
├── App.config
├── Mediator.csproj
├── MovieTheatreConcessions.cs
├── Program.cs
└── Properties
│ └── AssemblyInfo.cs
├── Memento
├── App.config
├── FoodSupplier.cs
├── Memento.csproj
├── Program.cs
└── Properties
│ └── AssemblyInfo.cs
├── Observer
├── App.config
├── Observer.csproj
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
└── VeggiePrices.cs
├── Prototype
├── App.config
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── Prototype.csproj
└── Sandwiches.cs
├── Proxy
├── App.config
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── Proxy.csproj
└── Server.cs
├── README.md
├── Singleton
├── App.config
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── Singleton.csproj
└── TheBell.cs
├── State
├── App.config
├── BeefDoneness.cs
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
└── State.csproj
├── Strategy
├── App.config
├── CookMethod.cs
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
└── Strategy.csproj
├── TemplateMethod
├── App.config
├── FreshBread.cs
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
└── TemplateMethod.csproj
└── Visitor
├── App.config
├── Patron.cs
├── Program.cs
├── Properties
└── AssemblyInfo.cs
└── Visitor.csproj
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | build/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 |
28 | # MSTest test Results
29 | [Tt]est[Rr]esult*/
30 | [Bb]uild[Ll]og.*
31 |
32 | # NUNIT
33 | *.VisualState.xml
34 | TestResult.xml
35 |
36 | # Build Results of an ATL Project
37 | [Dd]ebugPS/
38 | [Rr]eleasePS/
39 | dlldata.c
40 |
41 | # DNX
42 | project.lock.json
43 | artifacts/
44 |
45 | *_i.c
46 | *_p.c
47 | *_i.h
48 | *.ilk
49 | *.meta
50 | *.obj
51 | *.pch
52 | *.pdb
53 | *.pgc
54 | *.pgd
55 | *.rsp
56 | *.sbr
57 | *.tlb
58 | *.tli
59 | *.tlh
60 | *.tmp
61 | *.tmp_proj
62 | *.log
63 | *.vspscc
64 | *.vssscc
65 | .builds
66 | *.pidb
67 | *.svclog
68 | *.scc
69 |
70 | # Chutzpah Test files
71 | _Chutzpah*
72 |
73 | # Visual C++ cache files
74 | ipch/
75 | *.aps
76 | *.ncb
77 | *.opensdf
78 | *.sdf
79 | *.cachefile
80 |
81 | # Visual Studio profiler
82 | *.psess
83 | *.vsp
84 | *.vspx
85 |
86 | # TFS 2012 Local Workspace
87 | $tf/
88 |
89 | # Guidance Automation Toolkit
90 | *.gpState
91 |
92 | # ReSharper is a .NET coding add-in
93 | _ReSharper*/
94 | *.[Rr]e[Ss]harper
95 | *.DotSettings.user
96 |
97 | # JustCode is a .NET coding add-in
98 | .JustCode
99 |
100 | # TeamCity is a build add-in
101 | _TeamCity*
102 |
103 | # DotCover is a Code Coverage Tool
104 | *.dotCover
105 |
106 | # NCrunch
107 | _NCrunch_*
108 | .*crunch*.local.xml
109 |
110 | # MightyMoose
111 | *.mm.*
112 | AutoTest.Net/
113 |
114 | # Web workbench (sass)
115 | .sass-cache/
116 |
117 | # Installshield output folder
118 | [Ee]xpress/
119 |
120 | # DocProject is a documentation generator add-in
121 | DocProject/buildhelp/
122 | DocProject/Help/*.HxT
123 | DocProject/Help/*.HxC
124 | DocProject/Help/*.hhc
125 | DocProject/Help/*.hhk
126 | DocProject/Help/*.hhp
127 | DocProject/Help/Html2
128 | DocProject/Help/html
129 |
130 | # Click-Once directory
131 | publish/
132 |
133 | # Publish Web Output
134 | *.[Pp]ublish.xml
135 | *.azurePubxml
136 | ## TODO: Comment the next line if you want to checkin your
137 | ## web deploy settings but do note that will include unencrypted
138 | ## passwords
139 | #*.pubxml
140 |
141 | *.publishproj
142 |
143 | # NuGet Packages
144 | *.nupkg
145 | # The packages folder can be ignored because of Package Restore
146 | **/packages/*
147 | # except build/, which is used as an MSBuild target.
148 | !**/packages/build/
149 | # Uncomment if necessary however generally it will be regenerated when needed
150 | #!**/packages/repositories.config
151 |
152 | # Windows Azure Build Output
153 | csx/
154 | *.build.csdef
155 |
156 | # Windows Store app package directory
157 | AppPackages/
158 |
159 | # Visual Studio cache files
160 | # files ending in .cache can be ignored
161 | *.[Cc]ache
162 | # but keep track of directories ending in .cache
163 | !*.[Cc]ache/
164 |
165 | # Others
166 | ClientBin/
167 | [Ss]tyle[Cc]op.*
168 | ~$*
169 | *~
170 | *.dbmdl
171 | *.dbproj.schemaview
172 | *.pfx
173 | *.publishsettings
174 | node_modules/
175 | orleans.codegen.cs
176 |
177 | # RIA/Silverlight projects
178 | Generated_Code/
179 |
180 | # Backup & report files from converting an old project file
181 | # to a newer Visual Studio version. Backup files are not needed,
182 | # because we have git ;-)
183 | _UpgradeReport_Files/
184 | Backup*/
185 | UpgradeLog*.XML
186 | UpgradeLog*.htm
187 |
188 | # SQL Server files
189 | *.mdf
190 | *.ldf
191 |
192 | # Business Intelligence projects
193 | *.rdl.data
194 | *.bim.layout
195 | *.bim_*.settings
196 |
197 | # Microsoft Fakes
198 | FakesAssemblies/
199 |
200 | # Node.js Tools for Visual Studio
201 | .ntvs_analysis.dat
202 |
203 | # Visual Studio 6 build log
204 | *.plg
205 |
206 | # Visual Studio 6 workspace options file
207 | *.opt
208 |
209 | # LightSwitch generated files
210 | GeneratedArtifacts/
211 | _Pvt_Extensions/
212 | ModelManifest.xml
213 |
--------------------------------------------------------------------------------
/AbstractFactory/AbstractFactory.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {67F0E1E6-0E12-40F5-B71F-EC9E217914F7}
8 | Exe
9 | Properties
10 | AbstractFactory
11 | AbstractFactory
12 | v4.7.2
13 | 512
14 | true
15 |
16 |
17 |
18 | AnyCPU
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 |
27 |
28 | AnyCPU
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
62 |
--------------------------------------------------------------------------------
/AbstractFactory/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/AbstractFactory/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace AbstractFactory
8 | {
9 | class Program
10 | {
11 | ///
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 | ///
16 | ///
17 | static void Main(string[] args)
18 | {
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;
27 |
28 | case 'C':
29 | factory = new KidCuisineFactory();
30 | break;
31 |
32 | default:
33 | throw new NotImplementedException();
34 |
35 | }
36 |
37 | var sandwich = factory.CreateSandwich();
38 | var dessert = factory.CreateDessert();
39 |
40 | Console.WriteLine("\nSandwich: " + sandwich.GetType().Name);
41 | Console.WriteLine("Dessert: " + dessert.GetType().Name);
42 |
43 | Console.ReadKey();
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/AbstractFactory/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("AbstractFactory")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("AbstractFactory")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("67f0e1e6-0e12-40f5-b71f-ec9e217914f7")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/AbstractFactory/RecipeFactory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace AbstractFactory
8 | {
9 | ///
10 | /// An abstract product.
11 | ///
12 | abstract class Sandwich { }
13 |
14 | ///
15 | /// An abstract product.
16 | ///
17 | abstract class Dessert { }
18 |
19 | ///
20 | /// The Abstract Factory class, which defines methods for creating abstract objects.
21 | ///
22 | abstract class RecipeFactory
23 | {
24 | public abstract Sandwich CreateSandwich();
25 | public abstract Dessert CreateDessert();
26 | }
27 |
28 | ///
29 | /// A concrete product
30 | ///
31 | class BLT : Sandwich { }
32 |
33 | ///
34 | /// A concrete product
35 | ///
36 | class CremeBrulee : Dessert { }
37 |
38 |
39 | ///
40 | /// A concrete factory which creates concrete objects by implementing the abstract factory's methods.
41 | ///
42 | class AdultCuisineFactory : RecipeFactory
43 | {
44 | public override Sandwich CreateSandwich()
45 | {
46 | return new BLT();
47 | }
48 |
49 | public override Dessert CreateDessert()
50 | {
51 | return new CremeBrulee();
52 | }
53 | }
54 |
55 | ///
56 | /// A concrete product
57 | ///
58 | class PBandJ : Sandwich { }
59 |
60 | ///
61 | /// A concrete product
62 | ///
63 | class IceCreamSundae : Dessert { }
64 |
65 | ///
66 | /// A concrete factory which creates concrete objects by implementing the abstract factory's methods.
67 | ///
68 | class KidCuisineFactory : RecipeFactory
69 | {
70 | public override Sandwich CreateSandwich()
71 | {
72 | return new PBandJ();
73 | }
74 |
75 | public override Dessert CreateDessert()
76 | {
77 | return new IceCreamSundae();
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/Adapter/Adapter.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {7EAE4108-CF20-42E8-B011-8D9F2F891026}
8 | Exe
9 | Properties
10 | Adapter
11 | Adapter
12 | v4.7.2
13 | 512
14 | true
15 |
16 |
17 |
18 | AnyCPU
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 |
27 |
28 | AnyCPU
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
62 |
--------------------------------------------------------------------------------
/Adapter/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Adapter/Meats.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Adapter
8 | {
9 | public enum TemperatureType
10 | {
11 | Fahrenheit,
12 | Celsius
13 | }
14 | ///
15 | /// The legacy API which must be converted to the new structure (aka the Adaptee participant)
16 | ///
17 | class MeatDatabase
18 | {
19 | // Temps from http://www.foodsafety.gov/keep/charts/mintemp.html
20 | public float GetSafeCookTemp(string meat, TemperatureType tempType)
21 | {
22 | if (tempType == TemperatureType.Fahrenheit)
23 | {
24 | switch (meat)
25 | {
26 | case "beef":
27 | case "pork":
28 | return 145f;
29 |
30 | case "chicken":
31 | case "turkey":
32 | return 165f;
33 |
34 | default:
35 | return 165f;
36 | }
37 | }
38 | else
39 | {
40 | switch (meat)
41 | {
42 | case "beef":
43 | case "veal":
44 | case "pork":
45 | return 63f;
46 |
47 | case "chicken":
48 | case "turkey":
49 | return 74f;
50 |
51 | default:
52 | return 74f;
53 | }
54 | }
55 | }
56 |
57 | public int GetCaloriesPerOunce(string meat)
58 | {
59 | switch (meat.ToLower())
60 | {
61 | case "beef": return 71;
62 | case "pork": return 69;
63 | case "chicken": return 66;
64 | case "turkey": return 38;
65 | default: return 0;
66 | }
67 | }
68 |
69 | public double GetProteinPerOunce(string meat)
70 | {
71 | switch (meat.ToLower())
72 | {
73 | case "beef": return 7.33f;
74 | case "pork": return 7.67f;
75 | case "chicken": return 8.57f;
76 | case "turkey": return 8.5f;
77 | default: return 0d;
78 | }
79 | }
80 | }
81 |
82 | ///
83 | /// The Target participant, which represents details about a particular kind of meat.
84 | ///
85 | class Meat
86 | {
87 | protected string MeatName;
88 | protected float SafeCookTempFahrenheit;
89 | protected float SafeCookTempCelsius;
90 | protected double CaloriesPerOunce;
91 | protected double ProteinPerOunce;
92 |
93 | // Constructor
94 | public Meat(string meat)
95 | {
96 | this.MeatName = meat;
97 | }
98 |
99 | public virtual void LoadData()
100 | {
101 | Console.WriteLine("\nMeat: {0} ------ ", MeatName);
102 | }
103 | }
104 |
105 | ///
106 | /// The Adapter class, which wraps the Meat class and initializes that class's values.
107 | ///
108 | class MeatDetails : Meat
109 | {
110 | private MeatDatabase _meatDatabase;
111 |
112 | // Constructor
113 | public MeatDetails(string name)
114 | : base(name)
115 | {
116 | }
117 |
118 | public override void LoadData()
119 | {
120 | // The Adaptee
121 | _meatDatabase = new MeatDatabase();
122 |
123 | SafeCookTempFahrenheit = _meatDatabase.GetSafeCookTemp(MeatName, TemperatureType.Fahrenheit);
124 | SafeCookTempCelsius = _meatDatabase.GetSafeCookTemp(MeatName, TemperatureType.Celsius);
125 | CaloriesPerOunce = _meatDatabase.GetCaloriesPerOunce(MeatName);
126 | ProteinPerOunce = _meatDatabase.GetProteinPerOunce(MeatName);
127 |
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);
133 | }
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/Adapter/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Adapter
8 | {
9 | class Program
10 | {
11 | static void Main(string[] args)
12 | {
13 | //Non-adapted
14 | Meat unknown = new Meat("Beef");
15 | unknown.LoadData();
16 |
17 | //Adapted
18 | MeatDetails beef = new MeatDetails("Beef");
19 | beef.LoadData();
20 |
21 | MeatDetails turkey = new MeatDetails("Turkey");
22 | turkey.LoadData();
23 |
24 | MeatDetails chicken = new MeatDetails("Chicken");
25 | chicken.LoadData();
26 |
27 | Console.ReadKey();
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Adapter/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Adapter")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Adapter")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("7eae4108-cf20-42e8-b011-8d9f2f891026")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Bridge/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Bridge/Bridge.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {08ED1B4B-711C-4500-A380-F9454288E691}
8 | Exe
9 | Properties
10 | Bridge
11 | Bridge
12 | v4.7.2
13 | 512
14 | true
15 |
16 |
17 |
18 | AnyCPU
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 |
27 |
28 | AnyCPU
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
62 |
--------------------------------------------------------------------------------
/Bridge/OrderingSystem.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Bridge
8 | {
9 | ///
10 | /// Implementor which defines an interface for placing an order
11 | ///
12 | public interface IOrderingSystem
13 | {
14 | void Place(string order);
15 | }
16 |
17 | ///
18 | /// Abstraction which represents the sent order and maintains a reference to the restaurant where the order is going.
19 | ///
20 | public abstract class SendOrder
21 | {
22 | //Reference to the Implementor
23 | public IOrderingSystem _restaurant;
24 |
25 | public abstract void Send();
26 | }
27 |
28 | ///
29 | /// Refined abstraction for a dairy-free order
30 | ///
31 | public class SendDairyFreeOrder : SendOrder
32 | {
33 | public override void Send()
34 | {
35 | _restaurant.Place("Dairy-Free Order");
36 | }
37 | }
38 |
39 | ///
40 | /// Refined abstraction for a gluten free order
41 | ///
42 | public class SendGlutenFreeOrder : SendOrder
43 | {
44 | public override void Send()
45 | {
46 | _restaurant.Place("Gluten-Free Order");
47 | }
48 | }
49 |
50 | ///
51 | /// Concrete implementor for an ordering system at a diner.
52 | ///
53 | public class DinerOrders : IOrderingSystem
54 | {
55 | public void Place(string order)
56 | {
57 | Console.WriteLine("Placing order for " + order + " at the Diner.");
58 | }
59 | }
60 |
61 | ///
62 | /// Concrete implementor for an ordering system at a fancy restaurant.
63 | ///
64 | public class FancyRestaurantOrders : IOrderingSystem
65 | {
66 | public void Place(string order)
67 | {
68 | Console.WriteLine("Placing order for " + order + " at the Fancy Restaurant.");
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/Bridge/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Bridge
8 | {
9 | class Program
10 | {
11 | static void Main(string[] args)
12 | {
13 | SendOrder _sendOrder = new SendDairyFreeOrder();
14 | _sendOrder._restaurant = new DinerOrders();
15 | _sendOrder.Send();
16 |
17 | _sendOrder._restaurant = new FancyRestaurantOrders();
18 | _sendOrder.Send();
19 |
20 | _sendOrder = new SendGlutenFreeOrder();
21 | _sendOrder._restaurant = new DinerOrders();
22 | _sendOrder.Send();
23 |
24 | _sendOrder._restaurant = new FancyRestaurantOrders();
25 | _sendOrder.Send();
26 |
27 | Console.ReadKey();
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Bridge/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Bridge")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Bridge")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("08ed1b4b-711c-4500-a380-f9454288e691")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Builder/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Builder/Builder.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {ECD40C19-C21B-453B-A57C-22BC884F12CB}
8 | Exe
9 | Properties
10 | Builder
11 | Builder
12 | v4.7.2
13 | 512
14 | true
15 |
16 |
17 |
18 | AnyCPU
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 |
27 |
28 | AnyCPU
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
62 |
--------------------------------------------------------------------------------
/Builder/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Builder
8 | {
9 | class Program
10 | {
11 | static void Main(string[] args)
12 | {
13 | SandwichBuilder builder;
14 |
15 | // Create deli with sandwich assembly line
16 | AssemblyLine shop = new AssemblyLine();
17 |
18 | // Construct and display sandwiches
19 | builder = new HamAndCheese();
20 | shop.Assemble(builder);
21 | builder.Sandwich.Show();
22 |
23 | builder = new BLT();
24 | shop.Assemble(builder);
25 | builder.Sandwich.Show();
26 |
27 | builder = new TurkeyClub();
28 | shop.Assemble(builder);
29 | builder.Sandwich.Show();
30 |
31 | // Wait for user
32 | Console.ReadKey();
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Builder/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Builder")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Builder")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("ecd40c19-c21b-453b-a57c-22bc884f12cb")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Builder/SandwichAssemblyLine.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Builder
8 | {
9 | ///
10 | /// The Director
11 | ///
12 | class AssemblyLine
13 | {
14 | // Builder uses a complex series of steps
15 | //
16 | public void Assemble(SandwichBuilder sandwichBuilder)
17 | {
18 | sandwichBuilder.AddBread();
19 | sandwichBuilder.AddMeats();
20 | sandwichBuilder.AddCheese();
21 | sandwichBuilder.AddVeggies();
22 | sandwichBuilder.AddCondiments();
23 | }
24 | }
25 |
26 | ///
27 | /// The Builder abstract class
28 | ///
29 | abstract class SandwichBuilder
30 | {
31 | protected Sandwich sandwich;
32 |
33 | // Gets sandwich instance
34 | public Sandwich Sandwich
35 | {
36 | get { return sandwich; }
37 | }
38 |
39 | // Abstract build methods
40 | public abstract void AddBread();
41 | public abstract void AddMeats();
42 | public abstract void AddCheese();
43 | public abstract void AddVeggies();
44 | public abstract void AddCondiments();
45 | }
46 |
47 | ///
48 | /// A Concrete Builder class
49 | ///
50 | class TurkeyClub : SandwichBuilder
51 | {
52 | public TurkeyClub()
53 | {
54 | sandwich = new Sandwich("Turkey Club");
55 | }
56 |
57 | public override void AddBread()
58 | {
59 | sandwich["bread"] = "12-Grain";
60 | }
61 |
62 | public override void AddMeats()
63 | {
64 | sandwich["meat"] = "Turkey";
65 | }
66 |
67 | public override void AddCheese()
68 | {
69 | sandwich["cheese"] = "Swiss";
70 | }
71 |
72 | public override void AddVeggies()
73 | {
74 | sandwich["veggies"] = "Lettuce, Tomato";
75 | }
76 |
77 | public override void AddCondiments()
78 | {
79 | sandwich["condiments"] = "Mayo";
80 | }
81 | }
82 |
83 |
84 | ///
85 | /// A Concrete Builder class
86 | ///
87 | class BLT : SandwichBuilder
88 | {
89 | public BLT()
90 | {
91 | sandwich = new Sandwich("BLT");
92 | }
93 |
94 | public override void AddBread()
95 | {
96 | sandwich["bread"] = "Wheat";
97 | }
98 |
99 | public override void AddMeats()
100 | {
101 | sandwich["meat"] = "Bacon";
102 | }
103 |
104 | public override void AddCheese()
105 | {
106 | sandwich["cheese"] = "None";
107 | }
108 |
109 | public override void AddVeggies()
110 | {
111 | sandwich["veggies"] = "Lettuce, Tomato";
112 | }
113 |
114 | public override void AddCondiments()
115 | {
116 | sandwich["condiments"] = "Mayo, Mustard";
117 | }
118 | }
119 |
120 | ///
121 | /// A Concrete Builder class
122 | ///
123 | class HamAndCheese : SandwichBuilder
124 | {
125 | public HamAndCheese()
126 | {
127 | sandwich = new Sandwich("Ham and Cheese");
128 | }
129 |
130 | public override void AddBread()
131 | {
132 | sandwich["bread"] = "White";
133 | }
134 |
135 | public override void AddMeats()
136 | {
137 | sandwich["meat"] = "Ham";
138 | }
139 |
140 | public override void AddCheese()
141 | {
142 | sandwich["cheese"] = "American";
143 | }
144 |
145 | public override void AddVeggies()
146 | {
147 | sandwich["veggies"] = "None";
148 | }
149 |
150 | public override void AddCondiments()
151 | {
152 | sandwich["condiments"] = "Mayo";
153 | }
154 | }
155 |
156 | ///
157 | /// The Product class
158 | ///
159 | class Sandwich
160 | {
161 | private string _sandwichType;
162 | private Dictionary _ingredients = new Dictionary();
163 |
164 | // Constructor
165 | public Sandwich(string sandwichType)
166 | {
167 | this._sandwichType = sandwichType;
168 | }
169 |
170 | // Indexer
171 | public string this[string key]
172 | {
173 | get { return _ingredients[key]; }
174 | set { _ingredients[key] = value; }
175 | }
176 |
177 | public void Show()
178 | {
179 | Console.WriteLine("\n---------------------------");
180 | Console.WriteLine("Sandwich: {0}", _sandwichType);
181 | Console.WriteLine(" Bread: {0}", _ingredients["bread"]);
182 | Console.WriteLine(" Meat: {0}", _ingredients["meat"]);
183 | Console.WriteLine(" Cheese: {0}", _ingredients["cheese"]);
184 | Console.WriteLine(" Veggies: {0}", _ingredients["veggies"]);
185 | Console.WriteLine(" Condiments: {0}", _ingredients["condiments"]);
186 | }
187 | }
188 | }
189 |
--------------------------------------------------------------------------------
/ChainOfResponsibility/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/ChainOfResponsibility/ChainOfResponsibility.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {E3356AE6-5B85-4163-B647-EFD7DC544FFC}
8 | Exe
9 | Properties
10 | ChainOfResponsibility
11 | ChainOfResponsibility
12 | v4.7.2
13 | 512
14 | true
15 |
16 |
17 |
18 | AnyCPU
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 |
27 |
28 | AnyCPU
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
62 |
--------------------------------------------------------------------------------
/ChainOfResponsibility/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ChainOfResponsibility
8 | {
9 | class Program
10 | {
11 | static void Main(string[] args)
12 | {
13 | //Create the chain links
14 | Approver jennifer = new HeadChef();
15 | Approver mitchell = new PurchasingManager();
16 | Approver olivia = new GeneralManager();
17 |
18 | //Create the chain
19 | jennifer.SetSupervisor(mitchell);
20 | mitchell.SetSupervisor(olivia);
21 |
22 | // Generate and process purchase requests
23 | PurchaseOrder p = new PurchaseOrder(1, 20, 69, "Spices");
24 | jennifer.ProcessRequest(p);
25 |
26 | p = new PurchaseOrder(2, 300, 1389, "Fresh Veggies");
27 | jennifer.ProcessRequest(p);
28 |
29 | p = new PurchaseOrder(3, 500, 4823.99, "Beef");
30 | jennifer.ProcessRequest(p);
31 |
32 | p = new PurchaseOrder(4, 4, 12099, "Ovens");
33 | jennifer.ProcessRequest(p);
34 |
35 | // Wait for user
36 | Console.ReadKey();
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/ChainOfResponsibility/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ChainOfResponsibility")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ChainOfResponsibility")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("e3356ae6-5b85-4163-b647-efd7dc544ffc")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ChainOfResponsibility/RestaurantRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ChainOfResponsibility
8 | {
9 | ///
10 | /// The Handler abstract class. Every class which inherits from this will be responsible for a kind of request for the restaurant.
11 | ///
12 | abstract class Approver
13 | {
14 | protected Approver Supervisor;
15 |
16 | public void SetSupervisor(Approver supervisor)
17 | {
18 | this.Supervisor = supervisor;
19 | }
20 |
21 | public abstract void ProcessRequest(PurchaseOrder purchase);
22 | }
23 |
24 | ///
25 | /// A concrete Handler class
26 | ///
27 | class HeadChef : Approver
28 | {
29 | public override void ProcessRequest(PurchaseOrder purchase)
30 | {
31 | if (purchase.Price < 1000)
32 | {
33 | Console.WriteLine("{0} approved purchase request #{1}",
34 | this.GetType().Name, purchase.RequestNumber);
35 | }
36 | else if (Supervisor != null)
37 | {
38 | Supervisor.ProcessRequest(purchase);
39 | }
40 | }
41 | }
42 |
43 | ///
44 | /// A concrete Handler class
45 | ///
46 | class PurchasingManager : Approver
47 | {
48 | public override void ProcessRequest(PurchaseOrder purchase)
49 | {
50 | if (purchase.Price < 2500)
51 | {
52 | Console.WriteLine("{0} approved purchase request #{1}",
53 | this.GetType().Name, purchase.RequestNumber);
54 | }
55 | else if (Supervisor != null)
56 | {
57 | Supervisor.ProcessRequest(purchase);
58 | }
59 | }
60 | }
61 |
62 | ///
63 | /// A concrete Handler class
64 | ///
65 | class GeneralManager : Approver
66 | {
67 | public override void ProcessRequest(PurchaseOrder purchase)
68 | {
69 | if (purchase.Price < 10000)
70 | {
71 | Console.WriteLine("{0} approved purchase request #{1}",
72 | this.GetType().Name, purchase.RequestNumber);
73 | }
74 | else
75 | {
76 | Console.WriteLine(
77 | "Purchase request #{0} requires an executive meeting!",
78 | purchase.RequestNumber);
79 | }
80 | }
81 | }
82 |
83 | ///
84 | /// The details of the purchase request.
85 | ///
86 | class PurchaseOrder
87 | {
88 |
89 | // Constructor
90 | public PurchaseOrder(int number, double amount, double price, string name)
91 | {
92 | RequestNumber = number;
93 | Amount = amount;
94 | Price = price;
95 | Name = name;
96 |
97 | Console.WriteLine("Purchase request for " + name + " (" + amount + " for $" + price.ToString() + ") has been submitted.");
98 | }
99 |
100 | public int RequestNumber { get; set; }
101 | public double Amount { get; set; }
102 | public double Price { get; set; }
103 | public string Name { get; set; }
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/Command/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Command/Command.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {442F8983-D130-4EDC-85FF-BD3372E40A25}
8 | Exe
9 | Properties
10 | Command
11 | Command
12 | v4.7.2
13 | 512
14 | true
15 |
16 |
17 |
18 | AnyCPU
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 |
27 |
28 | AnyCPU
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
62 |
--------------------------------------------------------------------------------
/Command/Ordering.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Command
8 | {
9 |
10 | ///
11 | /// The Invoker class
12 | ///
13 | public class Patron
14 | {
15 | private OrderCommand _orderCommand;
16 | private MenuItem _menuItem;
17 | private FastFoodOrder _order;
18 |
19 | public Patron()
20 | {
21 | _order = new FastFoodOrder();
22 | }
23 |
24 | public void SetCommand(int commandOption)
25 | {
26 | _orderCommand = new CommandFactory().GetCommand(commandOption);
27 | }
28 |
29 | public void SetMenuItem(MenuItem item)
30 | {
31 | _menuItem = item;
32 | }
33 |
34 | public void ExecuteCommand()
35 | {
36 | _order.ExecuteCommand(_orderCommand, _menuItem);
37 | }
38 |
39 | public void ShowCurrentOrder()
40 | {
41 | _order.ShowCurrentItems();
42 | }
43 | }
44 |
45 | ///
46 | /// The Receiver
47 | ///
48 | public class FastFoodOrder
49 | {
50 | public List