Skip to content

Commit

Permalink
Builder
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasCancio committed Jan 13, 2021
1 parent f063896 commit 1f4abe4
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 3 deletions.
40 changes: 40 additions & 0 deletions PatternsCriacao/Builder/AndroidBuilder.cs
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; }
}
}
}
8 changes: 8 additions & 0 deletions PatternsCriacao/Builder/Builder.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>
25 changes: 25 additions & 0 deletions PatternsCriacao/Builder/Celular.cs
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}";
}
}
}
17 changes: 17 additions & 0 deletions PatternsCriacao/Builder/Fabricante.cs
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();
}
}
}
16 changes: 16 additions & 0 deletions PatternsCriacao/Builder/ICelular.cs
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; }
}
}
38 changes: 38 additions & 0 deletions PatternsCriacao/Builder/IphoneBuilder.cs
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";
}
}
}
18 changes: 18 additions & 0 deletions PatternsCriacao/Builder/Program.cs
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}");

}
}
}
12 changes: 9 additions & 3 deletions PatternsCriacao/PatternsCriacao.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 1f4abe4

Please sign in to comment.