Skip to content

Commit b1b23ac

Browse files
committed
[Abstract factory] - extract classes to files.
1 parent a0a61a0 commit b1b23ac

25 files changed

+558
-319
lines changed

Abstract Factory/Abstract Factory.csproj

+22-2
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,32 @@
4242
<Reference Include="System.Xml" />
4343
</ItemGroup>
4444
<ItemGroup>
45-
<Compile Include="Program.Structural.cs" />
45+
<Compile Include="Read world code\Continent\AfricaFactory.cs" />
46+
<Compile Include="Read world code\Continent\AmericaFactory.cs" />
47+
<Compile Include="Read world code\Animals\AnimalWorld.cs" />
48+
<Compile Include="Read world code\Animals\Bison.cs" />
49+
<Compile Include="Read world code\Animals\Carnivore.cs" />
50+
<Compile Include="Read world code\Continent\ContinentFactory.cs" />
51+
<Compile Include="Read world code\Animals\Herbivore.cs" />
52+
<Compile Include="Read world code\Animals\Lion.cs" />
53+
<Compile Include="Structural codes\AbstractFactory.cs" />
54+
<Compile Include="Structural codes\AbstractProductA.cs" />
55+
<Compile Include="Structural codes\AbstractProductB.cs" />
56+
<Compile Include="Structural codes\Client.cs" />
57+
<Compile Include="Structural codes\ConcreteFactory1.cs" />
58+
<Compile Include="Structural codes\ConcreteFactory2.cs" />
59+
<Compile Include="Structural codes\Products\ProductA1.cs" />
60+
<Compile Include="Structural codes\Products\ProductA2.cs" />
61+
<Compile Include="Structural codes\Products\ProductB1.cs" />
62+
<Compile Include="Structural codes\Products\ProductB2.cs" />
63+
<Compile Include="Structural codes\Program.Structural.cs" />
4664
<Compile Include="Properties\AssemblyInfo.cs" />
65+
<Compile Include="Read world code\Animals\Wildebeest.cs" />
66+
<Compile Include="Read world code\Animals\Wolf.cs" />
4767
</ItemGroup>
4868
<ItemGroup>
4969
<None Include="App.config" />
50-
<Compile Include="Program.RealWorldCode.cs" />
70+
<Compile Include="Read world code\Program.RealWorldCode.cs" />
5171
</ItemGroup>
5272
<ItemGroup>
5373
<Content Include="Participants.txt" />

Abstract Factory/Program.RealWorldCode.cs

-160
This file was deleted.

Abstract Factory/Program.Structural.cs

-157
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/// <summary>
2+
/// Creates an instance of several families of classes.
3+
///
4+
/// Provide an interface for creating families of related or
5+
/// dependent objects without specifying their concrete classes.
6+
///
7+
/// Frequence of use: 5 high.
8+
/// </summary>
9+
namespace DoFactory.GangOfFour.Abstract.RealWorld
10+
{
11+
/// <summary>
12+
/// The 'Client' class
13+
/// </summary>
14+
class AnimalWorld
15+
{
16+
private Herbivore _herbivore;
17+
private Carnivore _carnivore;
18+
19+
// Constructor
20+
public AnimalWorld(ContinentFactory factory)
21+
{
22+
_carnivore = factory.CreateCarnivore();
23+
_herbivore = factory.CreateHerbivore();
24+
}
25+
26+
public void RunFoodChain()
27+
{
28+
_carnivore.Eat(_herbivore);
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)