예제 #1
0
        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();
        }
예제 #2
0
        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();
        }