Skip to content

Commit

Permalink
Factory
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasCancio committed Jan 13, 2021
1 parent 8c586a4 commit cde175b
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 0 deletions.
8 changes: 8 additions & 0 deletions PatternsCriacao/Factory/Factory.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>
20 changes: 20 additions & 0 deletions PatternsCriacao/Factory/FactoryMethod.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Factory
{
public class FactoryMethod
{
public IPersonagem Escolher_Personagem(string personagem)
{
switch (personagem)
{
case "Liu Kang": return new LiuKang();
case "SubZero": return new SubZero();
case "Scorpion": return new Scorpion();
default: return null;
}
}
}
}
9 changes: 9 additions & 0 deletions PatternsCriacao/Factory/IPersonagem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;

namespace Factory
{
public interface IPersonagem
{
void Escolhido();
}
}
12 changes: 12 additions & 0 deletions PatternsCriacao/Factory/LiuKang.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace Factory
{
public class LiuKang : IPersonagem
{
public void Escolhido()
{
Console.WriteLine("Liu Kang");
}
}
}
23 changes: 23 additions & 0 deletions PatternsCriacao/Factory/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;

namespace Factory
{
class Program
{
static void Main(string[] args)
{
FactoryMethod fm = new FactoryMethod();

Console.WriteLine("Liu Kang | SubZero | Scorpion");
Console.WriteLine();

Console.WriteLine("Escolha seu Personagem");
string escolha = Console.ReadLine();

IPersonagem personagem = fm.Escolher_Personagem(escolha);
Console.WriteLine();
Console.WriteLine("Você vai jogar com ");
personagem.Escolhido();
}
}
}
12 changes: 12 additions & 0 deletions PatternsCriacao/Factory/Scorpion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace Factory
{
public class Scorpion : IPersonagem
{
public void Escolhido()
{
Console.WriteLine("Scorpion");
}
}
}
12 changes: 12 additions & 0 deletions PatternsCriacao/Factory/SubZero.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace Factory
{
public class SubZero : IPersonagem
{
public void Escolhido()
{
Console.WriteLine("SubZero");
}
}
}
6 changes: 6 additions & 0 deletions PatternsCriacao/PatternsCriacao.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.30804.86
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Singleton", "Singleton\Singleton.csproj", "{0966E9CC-D967-44E6-B950-20DE58379278}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Factory", "Factory\Factory.csproj", "{BE1783A6-9D3A-4ABE-A001-526E07A599CF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +17,10 @@ Global
{0966E9CC-D967-44E6-B950-20DE58379278}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0966E9CC-D967-44E6-B950-20DE58379278}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0966E9CC-D967-44E6-B950-20DE58379278}.Release|Any CPU.Build.0 = Release|Any CPU
{BE1783A6-9D3A-4ABE-A001-526E07A599CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BE1783A6-9D3A-4ABE-A001-526E07A599CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BE1783A6-9D3A-4ABE-A001-526E07A599CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BE1783A6-9D3A-4ABE-A001-526E07A599CF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit cde175b

Please sign in to comment.