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
f063896
commit 1f4abe4
Showing
8 changed files
with
171 additions
and
3 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,40 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Builder | ||
{ | ||
public class AndroidBuilder : ICelular | ||
{ | ||
Celular celular; | ||
public AndroidBuilder() | ||
{ | ||
celular = new Celular("Android"); | ||
} | ||
|
||
public void BuildBateria() | ||
{ | ||
this.celular.bateria = "MAH_1500"; | ||
} | ||
|
||
public void BuildCamera() | ||
{ | ||
this.celular.camera = "15 MP"; | ||
} | ||
|
||
public void BuildSistema() | ||
{ | ||
this.celular.sistema = "Android 4.5"; | ||
} | ||
|
||
public void BuildTela() | ||
{ | ||
this.celular.tela = "7"; | ||
} | ||
|
||
public Celular Celular | ||
{ | ||
get { return this.celular; } | ||
} | ||
} | ||
} |
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,25 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Builder | ||
{ | ||
public class Celular | ||
{ | ||
public Celular(String nome) | ||
{ | ||
this.Nome = nome; | ||
} | ||
|
||
public string Nome { get; set; } | ||
public string tela { get; set; } | ||
public string bateria { get; set; } | ||
public string sistema { get; set; } | ||
public string camera { get; set; } | ||
|
||
public override string ToString() | ||
{ | ||
return $"\t{this.Nome} \nBateria:\t{this.bateria}\nTela:\t\t{this.tela}\nSistema:\t{this.sistema}\nCamera:\t\t{this.camera}"; | ||
} | ||
} | ||
} |
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 Builder | ||
{ | ||
public class Fabricante | ||
{ | ||
public void Construtor(ICelular celularBuilder) | ||
{ | ||
celularBuilder.BuildBateria(); | ||
celularBuilder.BuildSistema(); | ||
celularBuilder.BuildTela(); | ||
celularBuilder.BuildCamera(); | ||
} | ||
} | ||
} |
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,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Builder | ||
{ | ||
public interface ICelular | ||
{ | ||
void BuildTela(); | ||
void BuildBateria(); | ||
void BuildSistema(); | ||
void BuildCamera(); | ||
|
||
Celular Celular { get; } | ||
} | ||
} |
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,38 @@ | ||
using System; | ||
|
||
namespace Builder | ||
{ | ||
public class IphoneBuilder : ICelular | ||
{ | ||
Celular celular; | ||
public IphoneBuilder() | ||
{ | ||
celular = new Celular("Iphone"); | ||
} | ||
|
||
public Celular Celular | ||
{ | ||
get { return this.celular; } | ||
} | ||
|
||
public void BuildBateria() | ||
{ | ||
this.celular.bateria = "MAH_1500"; | ||
} | ||
|
||
public void BuildCamera() | ||
{ | ||
this.celular.camera = "16 MP"; | ||
} | ||
|
||
public void BuildSistema() | ||
{ | ||
this.celular.sistema = "iOS 11"; | ||
} | ||
|
||
public void BuildTela() | ||
{ | ||
this.celular.tela = "9"; | ||
} | ||
} | ||
} |
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,18 @@ | ||
using System; | ||
|
||
namespace Builder | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
Fabricante fabricante = new Fabricante(); | ||
|
||
ICelular celularBuilder = new IphoneBuilder(); | ||
|
||
fabricante.Construtor(celularBuilder); | ||
Console.WriteLine($"Celular Fabricado: \n\n{celularBuilder.Celular}"); | ||
|
||
} | ||
} | ||
} |
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