Skip to content

Commit

Permalink
Template Method
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasCancio committed Jan 15, 2021
1 parent 69cb37c commit 22d4c26
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 0 deletions.
6 changes: 6 additions & 0 deletions PatternsComportamentais/PatternsComportamentais.sln
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "State", "State\State.csproj
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Strategy", "Strategy\Strategy.csproj", "{E577FEAF-A388-4BBB-B9D8-DF84075F08DC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TemplateMethod", "TemplateMethod\TemplateMethod.csproj", "{EC0C8F7F-7972-4360-9F32-FDE0585D149D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -63,6 +65,10 @@ Global
{E577FEAF-A388-4BBB-B9D8-DF84075F08DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E577FEAF-A388-4BBB-B9D8-DF84075F08DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E577FEAF-A388-4BBB-B9D8-DF84075F08DC}.Release|Any CPU.Build.0 = Release|Any CPU
{EC0C8F7F-7972-4360-9F32-FDE0585D149D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EC0C8F7F-7972-4360-9F32-FDE0585D149D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EC0C8F7F-7972-4360-9F32-FDE0585D149D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EC0C8F7F-7972-4360-9F32-FDE0585D149D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
18 changes: 18 additions & 0 deletions PatternsComportamentais/TemplateMethod/AbstractClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;

namespace TemplateMethod
{
public abstract class AbstractClass
{
public abstract void PrimitveOperation1();

public abstract void PrimitveOperation2();

public void TemplateMethod()
{
PrimitveOperation1();
PrimitveOperation2();
Console.WriteLine();
}
}
}
17 changes: 17 additions & 0 deletions PatternsComportamentais/TemplateMethod/ConcreteClassA.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;

namespace TemplateMethod
{
public class ConcreteClassA : AbstractClass
{
public override void PrimitveOperation1()
{
Console.WriteLine("ConcreteClassA.PrimitveOperation1()");
}

public override void PrimitveOperation2()
{
Console.WriteLine("ConcreteClassA.PrimitveOperation2()");
}
}
}
17 changes: 17 additions & 0 deletions PatternsComportamentais/TemplateMethod/ConcreteClassB.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;

namespace TemplateMethod
{
public class ConcreteClassB : AbstractClass
{
public override void PrimitveOperation1()
{
Console.WriteLine("ConcreteClassB.PrimitveOperation1()");
}

public override void PrimitveOperation2()
{
Console.WriteLine("ConcreteClassB.PrimitveOperation2()");
}
}
}
18 changes: 18 additions & 0 deletions PatternsComportamentais/TemplateMethod/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;

namespace TemplateMethod
{
class Program
{
static void Main(string[] args)
{
AbstractClass abstrata_a = new ConcreteClassA();

abstrata_a.TemplateMethod();

AbstractClass abstrata_b = new ConcreteClassB();

abstrata_b.TemplateMethod();
}
}
}
8 changes: 8 additions & 0 deletions PatternsComportamentais/TemplateMethod/TemplateMethod.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

</Project>

0 comments on commit 22d4c26

Please sign in to comment.