예제 #1
0
        static void Main(string[] args)
        {
            List <Boleto> boletos = new List <Boleto>();

            boletos.Add(new Boleto(200));
            boletos.Add(new Boleto(300));
            boletos.Add(new Boleto(400));

            Fatura fatura = new Fatura("Caelum", 900);

            ProcessadorDeBoletos pdb = new ProcessadorDeBoletos();

            pdb.Processa(boletos, fatura);

            Console.WriteLine(fatura.Pago);
            Console.ReadLine();
        }
        public void Processa(List <Boleto> boletos, Fatura fatura)
        {
            double total = 0;

            foreach (Boleto boleto in boletos)
            {
                Pagamento pagamento = new Pagamento(boleto.Valor, MeioDePagamento.BOLETO);
                fatura.Pagamentos.Add(pagamento);

                total += boleto.Valor;
            }

            // Marcar como pago deveria ser responsabilidade da Fatura
            if (total >= fatura.Valor)
            {
                fatura.Pago = true;
            }
        }