forked from LucasCancio/design-patterns
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c586a4
commit cde175b
Showing
8 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System; | ||
|
||
namespace Factory | ||
{ | ||
public interface IPersonagem | ||
{ | ||
void Escolhido(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters