Skip to content

Commit f9d8732

Browse files
committed
Abstract factory is done
1 parent 4a1c20d commit f9d8732

40 files changed

+490
-2
lines changed

.vscode/launch.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@
3131
"stopAtEntry": false,
3232
"internalConsoleOptions": "openOnSessionStart"
3333
},
34+
{
35+
"name": "AbstractFactory",
36+
"type": "coreclr",
37+
"request": "launch",
38+
"preLaunchTask": "build",
39+
// If you have changed target frameworks, make sure to update the program path.
40+
"program": "${workspaceRoot}/AbstractFactory/bin/Debug/netcoreapp2.0/AbstractFactory.dll",
41+
"args": [],
42+
"cwd": "${workspaceRoot}/AbstractFactory",
43+
// For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
44+
"console": "internalConsole",
45+
"stopAtEntry": false,
46+
"internalConsoleOptions": "openOnSessionStart"
47+
},
3448
{
3549
"name": ".NET Core Attach",
3650
"type": "coreclr",

AbstractFactory/.vscode/launch.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
// Use IntelliSense to find out which attributes exist for C# debugging
3+
// Use hover for the description of the existing attributes
4+
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": ".NET Core Launch (console)",
9+
"type": "coreclr",
10+
"request": "launch",
11+
"preLaunchTask": "build",
12+
// If you have changed target frameworks, make sure to update the program path.
13+
"program": "${workspaceFolder}/bin/Debug/netcoreapp2.0/AbstractFactory.dll",
14+
"args": [],
15+
"cwd": "${workspaceFolder}",
16+
// For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
17+
"console": "internalConsole",
18+
"stopAtEntry": false,
19+
"internalConsoleOptions": "openOnSessionStart"
20+
},
21+
{
22+
"name": ".NET Core Attach",
23+
"type": "coreclr",
24+
"request": "attach",
25+
"processId": "${command:pickProcess}"
26+
}
27+
]
28+
}

AbstractFactory/.vscode/tasks.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"taskName": "build",
6+
"command": "dotnet",
7+
"type": "process",
8+
"args": [
9+
"build",
10+
"${workspaceFolder}/AbstractFactory.csproj"
11+
],
12+
"problemMatcher": "$msCompile"
13+
}
14+
]
15+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp2.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
</Project>

AbstractFactory/Classes/Cheese.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace AbstractFactory.Classes
2+
{
3+
public class Cheese
4+
{
5+
6+
}
7+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace AbstractFactory.Classes
2+
{
3+
internal class ChicagoGarlic : Veggies
4+
{
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace AbstractFactory.Classes
2+
{
3+
internal class ChicagoMushroom : Veggies
4+
{
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace AbstractFactory.Classes
2+
{
3+
internal class ChicagoOnion : Veggies
4+
{
5+
}
6+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
namespace AbstractFactory.Classes
2+
{
3+
public class ChicagoPizzaIngredientFactory : IPizzaIngredientFactory
4+
{
5+
public Cheese CreateCheese()
6+
{
7+
return new ChicagoSheese();
8+
}
9+
10+
public Clams CreateClams()
11+
{
12+
return new FreshChicagoClams();
13+
}
14+
15+
public Dough CreateDough()
16+
{
17+
return new ThinCrustChicagoDough();
18+
}
19+
20+
public Pepperoni CreatePepperoni()
21+
{
22+
return new SlicedChicagoPepperoni();
23+
}
24+
25+
public Sauce CreateSauce()
26+
{
27+
return new MarinaraChicagoSause();
28+
}
29+
30+
public Veggies[] CreateVeggies()
31+
{
32+
return new Veggies [] {new ChicagoOnion(), new ChicagoGarlic(), new ChicagoMushroom(), new ChicagoRedPepper()};
33+
}
34+
}
35+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
3+
namespace AbstractFactory.Classes
4+
{
5+
public class ChicagoPizzaStore : PizzaStore
6+
{
7+
protected override Pizza CreatePizza(string pizzaType)
8+
{
9+
var ingredientFactory = new ChicagoPizzaIngredientFactory();
10+
Pizza pizza;
11+
switch(pizzaType)
12+
{
13+
case "cheese":
14+
pizza = new SheesePizza("Chicago Cheese Pizza", ingredientFactory);
15+
break;
16+
case "clam":
17+
pizza = new ClamPizza("Chicago Clam pizza", ingredientFactory);
18+
break;
19+
default:
20+
throw new InvalidOperationException("Pizza type is not found");
21+
break;
22+
}
23+
24+
return pizza;
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)