diff --git a/PatternsCriacao/Builder/AndroidBuilder.cs b/PatternsCriacao/Builder/AndroidBuilder.cs new file mode 100644 index 0000000..3bd5945 --- /dev/null +++ b/PatternsCriacao/Builder/AndroidBuilder.cs @@ -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; } + } + } +} diff --git a/PatternsCriacao/Builder/Builder.csproj b/PatternsCriacao/Builder/Builder.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/PatternsCriacao/Builder/Builder.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + diff --git a/PatternsCriacao/Builder/Celular.cs b/PatternsCriacao/Builder/Celular.cs new file mode 100644 index 0000000..f15e41d --- /dev/null +++ b/PatternsCriacao/Builder/Celular.cs @@ -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}"; + } + } +} diff --git a/PatternsCriacao/Builder/Fabricante.cs b/PatternsCriacao/Builder/Fabricante.cs new file mode 100644 index 0000000..84f85bb --- /dev/null +++ b/PatternsCriacao/Builder/Fabricante.cs @@ -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(); + } + } +} diff --git a/PatternsCriacao/Builder/ICelular.cs b/PatternsCriacao/Builder/ICelular.cs new file mode 100644 index 0000000..bb24034 --- /dev/null +++ b/PatternsCriacao/Builder/ICelular.cs @@ -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; } + } +} diff --git a/PatternsCriacao/Builder/IphoneBuilder.cs b/PatternsCriacao/Builder/IphoneBuilder.cs new file mode 100644 index 0000000..7c9c8dd --- /dev/null +++ b/PatternsCriacao/Builder/IphoneBuilder.cs @@ -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"; + } + } +} diff --git a/PatternsCriacao/Builder/Program.cs b/PatternsCriacao/Builder/Program.cs new file mode 100644 index 0000000..10550c1 --- /dev/null +++ b/PatternsCriacao/Builder/Program.cs @@ -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}"); + + } + } +} diff --git a/PatternsCriacao/PatternsCriacao.sln b/PatternsCriacao/PatternsCriacao.sln index c8fc20b..4bccf63 100644 --- a/PatternsCriacao/PatternsCriacao.sln +++ b/PatternsCriacao/PatternsCriacao.sln @@ -3,11 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 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}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Singleton", "Singleton\Singleton.csproj", "{0966E9CC-D967-44E6-B950-20DE58379278}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FactoryMethod", "FactoryMethod\FactoryMethod.csproj", "{BE1783A6-9D3A-4ABE-A001-526E07A599CF}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FactoryMethod", "FactoryMethod\FactoryMethod.csproj", "{BE1783A6-9D3A-4ABE-A001-526E07A599CF}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AbstractFactory", "AbstractFactory\AbstractFactory.csproj", "{5AB4FAA5-466E-4A89-864C-4EA395402008}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbstractFactory", "AbstractFactory\AbstractFactory.csproj", "{5AB4FAA5-466E-4A89-864C-4EA395402008}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Builder", "Builder\Builder.csproj", "{F6EE8C26-9785-4A05-A079-9E453345FF0E}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -27,6 +29,10 @@ Global {5AB4FAA5-466E-4A89-864C-4EA395402008}.Debug|Any CPU.Build.0 = Debug|Any CPU {5AB4FAA5-466E-4A89-864C-4EA395402008}.Release|Any CPU.ActiveCfg = Release|Any CPU {5AB4FAA5-466E-4A89-864C-4EA395402008}.Release|Any CPU.Build.0 = Release|Any CPU + {F6EE8C26-9785-4A05-A079-9E453345FF0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F6EE8C26-9785-4A05-A079-9E453345FF0E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F6EE8C26-9785-4A05-A079-9E453345FF0E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F6EE8C26-9785-4A05-A079-9E453345FF0E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE