static void Main(string[] args) { ItemNota item1 = new ItemNotaBuilder() .ComNome("item 1") .ComValor(100.0) .CriarItem(); ItemNota item2 = new ItemNotaBuilder() .ComNome("item 2") .ComValor(200.0) .CriarItem(); ItemNota item3 = new ItemNotaBuilder() .ComNome("item 3") .ComValor(300.0) .CriarItem(); NotaFiscal nf = new NotaFiscalBuilder() .ComRazaoSocial("Caelum") .ComCnpj("123.456.789/0001-10") .ComItem(item1) .ComItem(item2) .ComItem(item3) .ComObservacoes("entregar nf pessoalmente") .CriarNota(); Console.WriteLine(nf.ValorBruto); Console.ReadKey(); }
public static void Main(string[] args) { ItemDaNotaBuilder idnb = new ItemDaNotaBuilder(); idnb.ComDescricao("Item 1") .ComValor(100); ItemDaNota item1 = idnb.Constroi(); idnb = new ItemDaNotaBuilder(); idnb.ComDescricao("Item 2") .ComValor(200); ItemDaNota item2 = idnb.Constroi(); NotaFiscalBuilder builder = new NotaFiscalBuilder(new List <IAcaoAposGerarNota> { new EnviaPorEmail(), new NotaFiscalDAO(), new Multiplicador(2) }); builder.ParaEmpresa("Empresa Teste") .ComCnpj("123456789") .ComObservacoes("Observações da nota fiscal") .Com(item1) .Com(item2); NotaFiscal nf = builder.Constroi(); Console.WriteLine($"Valor da nota fiscal: R$ {nf.ValorBruto:F2}"); Console.WriteLine($"Valor dos impostos: R$ {nf.Impostos:F2}"); Console.ReadKey(); }
public static void CriandoNotaFiscal() { var item1 = new ItemDaNotaBuilder() .WithNome("Televisão") .WithValor(1200) .Build(); var item2 = new ItemDaNotaBuilder() .WithNome("Notebook") .WithValor(1500) .Build(); var item3 = new ItemDaNotaBuilder() .WithNome("Play Station 4") .WithValor(2900) .Build(); var nota = new NotaFiscalBuilder() .WithrazaoSocial("Loja do Brenner") .WithCnpj("24.093.094/0001.59") .WithData(DateTime.Now) .WithItem(item1) .WithItem(item2) .WithItem(item3) .WithObservacoes("Entregar no local de trabalho em horário comercial. ") .Build(); nota.Imprime(); }
static void Main(string[] args) { NotaFiscal notafiscal = new NotaFiscalBuilder().paraEmpresa("Diego Pimentel") .comCnpj("XXX.XXX.XXX/0001-XX") .comItemAdd(new ItemDaNota("Teclado", 45.0)) .comItemAdd(new ItemDaNota("Mouse", 12.0)) .comItemAdd(new ItemDaNota("Monitor", 300.0)) .comObservacao("Entregar nota fiscal em maos") .construir(); Console.WriteLine("Razao Social: " + notafiscal.getRazaoSocial() + "CNPJ: " + notafiscal.getCnpj() + "Valor: " + notafiscal.getValorBruto()); Console.ReadLine(); }
public static void Main(string[] args) { NotaFiscal nf = new NotaFiscalBuilder().ParaEmpresa("Caelum Ensino e Inovação") .ComCnpj("23.467.789/0001-12") .ComItem(new ItemNota("item 1", 100.0)) .ComItem(new ItemNota("item 2", 200.0)) .ComObservacoes("Uma obs qualquer") .NaData(new DateTime(2008, 04, 14)) .Constroi(); Console.WriteLine(nf.DataEmissao); Console.WriteLine(nf.ValBruto); Console.WriteLine(nf.Impostos); Console.ReadKey(); }
static void Main(string[] args) { NotaFiscalBuilder criador = new NotaFiscalBuilder(); criador.ParaEmpresa("Voonder Comercio Ltda") .ComCnpj("176.176.569.52") .NaDataAtual() .ComItem(new ItemDaNota("item 1", 100.0)) .ComItem(new ItemDaNota("item 2", 200.0)) .ComItem(new ItemDaNota("item 3", 300.0)) .ComObservacoes("Teste de desing pattern do Builder"); var nf = criador.Constroi(); Console.WriteLine(nf.ValorBruto); Console.WriteLine(nf.Impostos); Console.ReadKey(); }
static void Main(string[] args) { NotaFiscalBuilder criador = new NotaFiscalBuilder() .ParaEmpresa("Caelum") .ComCnpj("123.456.789/0001-10") .Com(new ItemDaNota("item 1", 100.0)) .Com(new ItemDaNota("item 2", 200.0)) .Com(new ItemDaNota("item 3", 300.0)) .ComObservacoes("entregar nf pessoalmente") .NaDataAtual(); criador.AdicionarAcao(new GravaNoBDcs()); criador.AdicionarAcao(new EnviaPorEmail()); criador.AdicionarAcao(new EnviaPorSMS()); NotaFiscal nf = criador.Constroi(); Console.WriteLine(nf.ValorBruto); Console.WriteLine(nf.Impostos); Console.ReadKey(); }
private static void Builder() { ItemDaNotaBuilder itemBuilder = new ItemDaNotaBuilder(); itemBuilder .ComNome("item1") .ComValor(100); var item1 = itemBuilder.Constroi(); itemBuilder .ComNome("item2") .ComValor(200); var item2 = itemBuilder.Constroi(); itemBuilder .ComNome("item3") .ComValor(200); var item3 = itemBuilder.Constroi(); NotaFiscalBuilder builder = new NotaFiscalBuilder(); builder .ComRazaoSocial("Filomeno Advogados") .ComCnpj("24.093.094/0001.59") .Com(item1) .Com(item2) .Com(item3) .ComObservacoes("uma observacao qualquer"); NotaFiscal nota = builder.Constroi(); nota.Imprime(); Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine("Builder"); Console.WriteLine(""); NotaFiscalBuilder builder = new NotaFiscalBuilder() .ParaEmpresa("123.456.789/0001-10", "N2S Software Ltda") .ParaDataAtual() .ComItem(new ItemDaNota("Notebook", 3500.0)) .ComItem(new ItemDaNota("Impressora", 1000.0)) .ComObservacoes("Nota de teste do design pattern builder"); NotaFiscal notaFiscal = builder.Build(); Console.WriteLine($"Cnpj: {notaFiscal.Cnpj}"); Console.WriteLine($"Razao Social: {notaFiscal.RazaoSocial}"); Console.WriteLine($"Valor Bruto: {notaFiscal.ValorBruto}"); Console.WriteLine($"Impostos: {notaFiscal.Impostos}"); Console.WriteLine($"Observacoes: {notaFiscal.Observacoes}"); Console.ReadKey(); }