예제 #1
0
        static void MenuCajaAhorro()
        {
            bool salir = false;

            while (!salir)
            {
                Console.Clear();
                Console.WriteLine("1- Consultar saldo.");
                Console.WriteLine("2- Acreditar saldo.");
                Console.WriteLine("3- Debitar saldo.");
                Console.WriteLine("4- Transferir a cuenta corriente.");
                Console.WriteLine("5- Salir.");
                string opcion = Console.ReadLine();
                Console.Clear();
                switch (opcion)
                {
                case "1":
                    Console.WriteLine("Saldo disponible: {0}", Controlador.ConsultarSaldoCA());
                    Console.ReadKey();
                    break;

                case "2":
                    try
                    {
                        Console.WriteLine("Ingrese saldo a acreditar: ");
                        Controlador.AcreditarSaldoCA(Convert.ToDouble(Console.ReadLine()));
                        Console.WriteLine();
                        Console.WriteLine("Saldo acreditado");
                    }
                    catch (SaldoInvalidoException ex)
                    {
                        Console.WriteLine(ex.Message);
                        Console.WriteLine("Stack trace: {0}", ex.StackTrace);
                    }
                    catch (Exception excepcion)
                    {
                        Console.WriteLine("Excepcion: " + excepcion.Message);
                        Console.WriteLine("Stack trace: {0}", excepcion.StackTrace);
                    }

                    Console.ReadKey();
                    break;

                case "3":
                    try
                    {
                        Console.WriteLine("Ingrese saldo a debitar: ");
                        Controlador.DebitarSaldoCA(Convert.ToDouble(Console.ReadLine()));
                        Console.WriteLine();
                        Console.WriteLine("Saldo debitado");
                    }
                    catch (SaldoInvalidoException ex)
                    {
                        Console.WriteLine(ex.Message);
                        Console.WriteLine("Stack trace: {0}", ex.StackTrace);
                    }
                    catch (SaldoInsuficienteException ex)
                    {
                        Console.WriteLine(ex.Message);
                        Console.WriteLine("Stack trace: {0}", ex.StackTrace);
                    }

                    catch (Exception excepcion)
                    {
                        Console.WriteLine("Excepcion: " + excepcion.Message);
                        Console.WriteLine("Stack trace: {0}", excepcion.StackTrace);
                    }
                    Console.ReadKey();
                    break;

                case "4":
                    try
                    {
                        Console.WriteLine("Ingrese saldo a transferir: ");
                        Controlador.TransferenciaCajaACorriente(Convert.ToDouble(Console.ReadLine()));
                        Console.WriteLine();
                        Console.WriteLine("Transferencia exitosa");
                    }
                    catch (SaldoInvalidoException ex)
                    {
                        Console.WriteLine(ex.Message);
                        Console.WriteLine("Stack trace: {0}", ex.StackTrace);
                    }
                    catch (SaldoInsuficienteException ex)
                    {
                        Console.WriteLine(ex.Message);
                        Console.WriteLine("Stack trace: {0}", ex.StackTrace);
                    }
                    catch (Exception excepcion)
                    {
                        Console.WriteLine("Excepcion: " + excepcion.Message);
                        Console.WriteLine("Stack trace: {0}", excepcion.StackTrace);
                    }
                    Console.ReadKey();
                    break;

                case "5":
                    salir = true;
                    break;

                default:
                    Console.WriteLine("Opcion invalida");
                    Console.ReadKey();
                    break;
                }
            }
        }