static void Main(string[] args) { Budget budget = new Budget(500.0); // IMPOST IImpost icms = new ICMS(); IImpost iss = new ISS(); IImpost iccc = new ICCC(); ImpostService impostService = new ImpostService(); // Console.WriteLine(impostService.Calculates(budget, icms)); // Console.WriteLine(impostService.Calculates(budget, iss)); // Console.WriteLine(impostService.Calculates(budget, iccc)); Account account = new Account(500.0); // INVESTMENT IInvestment conservative = new CONSERVATIVE(); IInvestment moderate = new MODERATE(); IInvestment bold = new BOLD(); InvestmentService investmentService = new InvestmentService(); investmentService.Calculates(account, conservative); investmentService.Calculates(account, moderate); investmentService.Calculates(account, bold); Console.ReadKey(); }
private static void TestaStrategyImpostoEInvesitmento() { var iss = new ISS(); var icms = new ICMS(); var iccc = new ICCC(); var orcamento = new Orcamento(500); var calculador = new CalculadorDeImpostos(); calculador.RealizaCalculo(orcamento, icms); calculador.RealizaCalculo(orcamento, iss); calculador.RealizaCalculo(orcamento, iccc); Console.ReadKey(); var conta = new Conta(); conta.Deposita(500); var investidor = new RealizadorDeInvestimentos(); var conservador = new Conservador(); var moderado = new Moderado(); var arrojado = new Arrojado(); investidor.RealizaInvestimento(conta, conservador); investidor.RealizaInvestimento(conta, moderado); investidor.RealizaInvestimento(conta, arrojado); Console.ReadKey(); }
static void Main(string[] args) { Imposto iccc = new ICCC(); Imposto iss = new ISS(); Orcamento orcamento = new Orcamento(500.0); CalculadorDeImposto calculador = new CalculadorDeImposto(); calculador.RealizaCalculo(orcamento, iss); calculador.RealizaCalculo(orcamento, iccc); Console.ReadKey(); }
static void Main(string[] args) { Imposto iss = new ISS(); Imposto icms = new ICMS(); Imposto iccc = new ICCC(); Orcamento orcamento = new Orcamento(5000); CalculadorDeImpostos calculador = new CalculadorDeImpostos(); calculador.RealizaCalculo(orcamento, iccc); Console.ReadKey(); }
public static void Main(string[] args) { Imposto iss = new ISS(); Imposto icms = new ICMS(); Imposto iccc = new ICCC(); Investimento cons = new Conservador(); Investimento moder = new Moderado(); Investimento arroj = new Arrojado(); Orcamento grana = new Orcamento(10000.0); CalculadorDeImpostos calculator = new CalculadorDeImpostos(); CalculaInvestimento calcInv = new CalculaInvestimento(); calculator.RealizaCalculo(grana, iccc); calcInv.calculaInvestimento(grana, arroj); }
static void TestaImposto() //Strategy { Imposto iss = new ISS(); Imposto icms = new ICMS(); Imposto iccc = new ICCC(); Orcamento orcamento = new Orcamento(1500.0); orcamento.AdicionaItem(new Item("CANETA", 250.0)); orcamento.AdicionaItem(new Item("LAPIS", 250.0)); orcamento.AdicionaItem(new Item("CANETA", 250.0)); CalculadorDeImposto calculador = new CalculadorDeImposto(); // Calculando o ISS calculador.RealizaCalculo(orcamento, iss); // Calculando o ICMS calculador.RealizaCalculo(orcamento, icms); calculador.RealizaCalculo(orcamento, iccc); calculador.RealizaCalculo(orcamento, new ICPP()); calculador.RealizaCalculo(orcamento, new IHIT()); }
static void Main(string[] args) { #region Strategy Orcamento orcamento = new Orcamento(); orcamento.Add(new Item("CANETA", 250.0)); orcamento.Add(new Item("LAPIS", 250.0)); IImposto novoImposto = new ICCC(); Console.WriteLine(novoImposto.Calcula(orcamento)); Console.ReadKey(); #endregion #region Chain of Responsibility CalculadorDeDescontos calculador = new CalculadorDeDescontos(); double desconto = calculador.Calcula(orcamento); Console.WriteLine(desconto); Console.ReadKey(); List <Request> requests = new List <Request>(); var xmlRequest = new Request(Format.XML); var csvRequest = new Request(Format.CSV); var percentRequest = new Request(Format.PERCENT); requests.Add(xmlRequest); requests.Add(csvRequest); requests.Add(percentRequest); var account = new Account("Raphael", "3252-2", 17508, 6000.99); var bankRequest = new BankRequester(); requests.ForEach(x => bankRequest.Response(x, account)); Console.ReadKey(); #endregion #region Template Method orcamento = new Orcamento(); orcamento.Add(new Item("CANETA", 250.0)); orcamento.Add(new Item("LAPIS", 250.0)); orcamento.Add(new Item("APAGADOR", 50.0)); orcamento.Add(new Item("BORRACHA", 10.0)); orcamento.Add(new Item("BORRACHA", 10.0)); orcamento.Add(new Item("BORRACHA", 10.0)); ICPP iCPP = new ICPP(); double tax; tax = iCPP.Calcula(orcamento); Console.WriteLine($"Valor do ICPP: {tax} "); IKCV iKCV = new IKCV(); tax = iKCV.Calcula(orcamento); Console.WriteLine($"Valor do IKCV: {tax} "); var iHIT = new IHIT(); tax = iHIT.Calcula(orcamento); Console.WriteLine($"Valor do IHIT: {tax} "); Console.ReadKey(); Bank bank = new Bank() { CorporateName = "Banco do Brasil S/A", Phone = "6666-12345", Address = "Av. Borges de Medeiros, Nº123", Email = "*****@*****.**", Date = DateTime.Now }; account = new Account("Pintado", "3252-2", 17508, 6000.99); IList <Account> accounts = new List <Account>(); accounts.Add(account); account = new Account("Raphael", "1404-5", 52223, 8500); accounts.Add(account); Console.WriteLine("Imprimindo relatório simplificado... "); IReport report = new SimpleReport(); report.Print(accounts, bank); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Imprimindo relatório completo... "); report = new ComplexReport(); report.Print(accounts, bank); Console.ReadKey(); #endregion #region Decorator e Comportamentos Compostos var iss = new ISS(new ICMS(new IKCV())); var imposto = new ImpostoAlto(new ICPP(new IHIT(new IKCV()))); orcamento = new Orcamento(); orcamento.Add(new Item("CANETA", 250.0)); orcamento.Add(new Item("LAPIS", 250.0)); double valor = imposto.Calcula(orcamento); Console.WriteLine($"Imposto Alto: R${valor}"); valor = iss.Calcula(orcamento); Console.WriteLine($"Valor do ISS: R${valor}"); Console.ReadKey(); account = new Account("Pintado", "3252-2", 17508, new DateTime(2015, 05, 07)); account.Deposit(50); accounts = new List <Account>(); accounts.Add(account); account = new Account("Raphael", "1404-5", 52223, new DateTime(2015, 05, 07)); account.Deposit(850000); accounts.Add(account); account = new Account("Teste", "3252-2", 666, 6500); accounts.Add(account); var filter = new CurrentMonthAccounts(new LowBallanceAccounts()); var filteredAccounts = filter.Search(accounts); bank = new Bank() { CorporateName = "Banco do Brasil S/A", Phone = "6666-12345", Address = "Av. Borges de Medeiros, Nº123", Email = "*****@*****.**", Date = DateTime.Now }; report = new ComplexReport(); report.Print(filteredAccounts, bank); Console.ReadKey(); #endregion #region State orcamento = new Orcamento(); orcamento.Add(new Item("Estados do Orçamento", 500)); Console.WriteLine($"Valor do Orçamento: R${orcamento.Valor}"); orcamento.ApplyExtraDiscount(); Console.WriteLine($"Orçamento em aprovação... Desconto extra de R${orcamento.Desconto}"); //orcamento.ApplyExtraDiscount(); teste para não aplicar desconto novamente no estado "Em aprovação" orcamento.Approves(); Console.WriteLine("Orçamento aprovado!"); orcamento.ApplyExtraDiscount(); Console.WriteLine($"Desconto extra de R${orcamento.Desconto}"); orcamento.Finalized(); Console.WriteLine("Orçamento finalizado!"); Console.WriteLine($"Orçamento final de R${orcamento.Valor}"); Console.ReadKey(); account = new Account("Pintado", "3252-2", 17508, 5000); account.CashWithDrawal(6000); Console.WriteLine("Saque Realizado!"); Console.WriteLine($"Nome:{account.Owner}, Saldo R${account.Balance}"); account.CashWithDrawal(2000); account.Deposit(2000); Console.WriteLine("Depósito Realizado!"); Console.WriteLine($"Nome:{account.Owner}, Saldo R${account.Balance}"); account.Deposit(2000); Console.WriteLine("Depósito Realizado!"); Console.WriteLine($"Nome:{account.Owner}, Saldo R${account.Balance}"); Console.ReadKey(); #endregion #region Builder var builder = new InvoiceBuilder(); builder.ToCompany("Alura Design Patterns LTDA.") .AddCnpj("45.429.459/0001-43") .Add(new InvoiceItem("Item 1", 100.0)) .Add(new InvoiceItem("Item 2", 200.0)) .AddObservation("Add some observation"); #region Observer Pattern Console.WriteLine(); Console.WriteLine("Executando ações de Observer pattern..."); builder.AddAction(new EmailSender()) .AddAction(new InvoiceDAO()) .AddAction(new SmsSender()) .AddAction(new Multiplier(5)); Console.WriteLine(); #endregion var nf = builder.Build(); Console.WriteLine(); Console.WriteLine($"Empresa: {nf.CorporateName}"); Console.WriteLine($"CNPJ {nf.Cnpj}"); Console.WriteLine($"Valor da Nota: R${nf.TotalValue}"); Console.WriteLine($"Taxas: R${nf.Taxes}"); Console.WriteLine($"Observações: {nf.Observations}"); Console.ReadKey(); #endregion }