private void Comprar(Cliente cliente) { // selecccionarTarjeta ArrayList tarjetas = serviceTarjeta.ObtenerTarjetas; if (tarjetas.Count == 0) { Console.Clear(); Console.WriteLine("No hay tarjetas registradas para poder abonar. Espere que seran cargadas."); Console.ReadKey(); return; } int i = 1; foreach (Tarjeta tarjetaa in tarjetas) { Console.WriteLine(i.ToString() + ") " + tarjetaa.InfoTarjeta); ArrayList formasPago = tarjetaa.InfoFormasPago; foreach (var formaPago in formasPago) { Console.WriteLine(" " + formaPago); } i++; } Console.WriteLine("Seleccione la tarjeta para abonar: "); int tarjetaSeleccionada = Int32.Parse(Console.ReadLine()); Tarjeta tarjetaSeleccionadaPago = (Tarjeta)tarjetas[tarjetaSeleccionada - 1]; // seleccionarCuotas Console.WriteLine("Indique cantidad de cuotas: "); int cantCuotas = Int32.Parse(Console.ReadLine()); // confirmacion double TotalEnCarro = calcularTotalCarro(); double interes = serviceTarjeta.obtenerInteres(tarjetaSeleccionadaPago, cantCuotas); Console.WriteLine("En " + cantCuotas.ToString() + " cuotas tiene un interes de " + interes.ToString() + "%"); Console.WriteLine("En el carro hay un total de " + TotalEnCarro.ToString()); double TotalFinanciado = serviceTarjeta.calculoIntereses(TotalEnCarro, tarjetaSeleccionadaPago, cantCuotas); Console.WriteLine("Precio total financiado:" + TotalFinanciado.ToString() + " en " + cantCuotas.ToString() + " cuotas de " + (TotalFinanciado / cantCuotas)); Console.WriteLine("Confirma la compra? (S/N)"); string confirmacion = Console.ReadLine(); if (confirmacion == "n" || confirmacion == "N") { Console.WriteLine("Compra cancelada"); return; } // actualizarGastosCliente cliente.TotalGastado = TotalFinanciado; // actualizarTotalComprado this.TotalComprado = this.TotalComprado + TotalFinanciado; // actualizar Compra con tarjeta tarjetaSeleccionadaPago.TotalCompras = TotalFinanciado; // vaciarCarrito carroDeCompras = new ArrayList(); Console.WriteLine("Felicidades por su compra, carro vacio!"); }
public double calculoIntereses(double total, Tarjeta tarjeta, int cuotas) { double interesesTotal = 0; double interes = obtenerInteres(tarjeta, cuotas); interesesTotal = total + (total * (interes / 100)); return(interesesTotal); }
public double obtenerInteres(Tarjeta tarjeta, int cuotas) { double interes = 0; foreach (ArrayList formaPago in tarjeta.FormasPago) { if ((int)formaPago[0] == cuotas) { interes = (int)formaPago[1]; } } return(interes); }
public void vistaIngresarBeneficio() { if (this.tarjetasAlmacenados.Count == 0) { Console.WriteLine("No hay tarjetas registradas. Presione una tecla para continuar.."); return; } listarTarjetas(); Console.WriteLine("Seleccione la tarjeta a la que desea agregar el beneficio: "); int tarjetaSeleccionada = Int32.Parse(Console.ReadLine()); Console.WriteLine("Indique cantidad de cuotas: "); int cantCuotas = Int32.Parse(Console.ReadLine()); Console.WriteLine("Indique interes por cuota: "); int interesCuota = Int32.Parse(Console.ReadLine()); Tarjeta tarjetaElegida = (Tarjeta)this.tarjetasAlmacenados[tarjetaSeleccionada - 1]; tarjetaElegida.ingresarBeneficio(cantCuotas, interesCuota); Console.WriteLine("Benificio Ingresado"); }
public void registrarTarjeta(string nombre, string banco, int cantidadFormasPago, ArrayList formasPago) { Tarjeta tarjetaNueva = new Tarjeta(nombre, banco, cantidadFormasPago, 0, formasPago); tarjetasAlmacenados.Add(tarjetaNueva); }