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
1f4abe4
commit 3fa1152
Showing
6 changed files
with
82 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
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,15 @@ | ||
using System; | ||
|
||
namespace Prototype | ||
{ | ||
public class FuncionarioPermanente : IFuncionario | ||
{ | ||
public string Nome { get; set; } | ||
public int Idade { get; set; } | ||
public string Tipo { get; set; } | ||
public IFuncionario Clone() | ||
{ | ||
return this.MemberwiseClone() as IFuncionario; | ||
} | ||
} | ||
} |
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,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Prototype | ||
{ | ||
public class FuncionarioTemporario : IFuncionario | ||
{ | ||
public string Nome { get; set; } | ||
public int Idade { get; set; } | ||
public string Tipo { get; set; } | ||
public IFuncionario Clone() | ||
{ | ||
return this.MemberwiseClone() as IFuncionario; | ||
} | ||
} | ||
} |
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 Prototype | ||
{ | ||
public interface IFuncionario | ||
{ | ||
IFuncionario Clone(); | ||
} | ||
} |
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,27 @@ | ||
using System; | ||
|
||
namespace Prototype | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
FuncionarioPermanente func_permanente = new FuncionarioPermanente | ||
{ | ||
Nome = "João", | ||
Idade = 30, | ||
Tipo = "Permanente" | ||
}; | ||
|
||
FuncionarioPermanente clone_func_permanente = (FuncionarioPermanente)func_permanente.Clone(); | ||
clone_func_permanente.Nome = "Carlos"; | ||
clone_func_permanente.Idade = 40; | ||
|
||
Console.WriteLine("Detalhes do funcionário Permanente:"); | ||
Console.WriteLine($"Nome: {func_permanente.Nome} \nIdade: {func_permanente.Idade} \nTipo: {func_permanente.Tipo}"); | ||
|
||
Console.WriteLine("\nDetalhes do funcionário Permanente Clonado:"); | ||
Console.WriteLine($"Nome: {clone_func_permanente.Nome} \nIdade: {clone_func_permanente.Idade} \nTipo: {clone_func_permanente.Tipo}"); | ||
} | ||
} | ||
} |
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> |