Ejemplo n.º 1
0
        public float Withdraw()

        {
            bankInfo details = new bankInfo();

            bankInfo.Comision c = Comission.Comision;

            string iban = rv.EnterCalulate();

            bankAccount account = rv.GetAccountByName(Calculate, _accounts);

            while (account == null)

            {
                Console.WriteLine("Account doesn't exist");

                iban = rv.EnterCalculate();

                account = rv.GetAccountByName(Calculate, _accounts);
            }

            float sum = rv.AmountToDeposit();

            while (sum <= 0)

            {
                Console.WriteLine("Amount cannot be less or equal than 0.");

                sum = 0;

                sum = rv.AmountToDeposit();
            }

            account.Sum -= sum;

            Console.Write("Withdrawn {0} from account {1}.", sum, Calculate);

            Console.WriteLine("Comision {0}", Math.Round(c(account.Sum), 2));

            account.Sum -= c(account.Sum);

            Console.WriteLine("Remaining: {0}", Math.Round(account.Sum, 2));

            return(account.Sum);
        }
        public static void App()

        {
            bankInfo bankdet = new bankInfo();

            ShowMenu();

            while (true)

            {
                Console.WriteLine("");

                string userInput = Console.ReadLine();

                switch (userInput)

                {
                case "a":

                    Console.WriteLine("'Citire din fisier' selected");

                    break;

                case "b":

                    Console.WriteLine("'Creare cont' selected");

                    Console.WriteLine("");

                    bankdet.CreateAccount("Name 1");

                    bankdet.CreateAccount("Name 2");

                    bankdet.CreateAccount("");

                    bankdet.CreateAccount("Name 4");

                    bankdet.CreateAccount("Name 5");

                    break;

                case "c":

                    Console.WriteLine("'Depunere bancara' selected");

                    bankdet.Deposit();

                    break;

                case "d":

                    Console.WriteLine("'Retragere bancara' selected");

                    bankdet.Withdraw();

                    break;

                case "e":

                    Console.WriteLine("'Afisare sold' selected");

                    bankdet.Balance();

                    break;

                case "f":

                    Environment.Exit(0);

                    break;

                default:

                    Console.WriteLine("Please select a valid option");

                    break;
                }
            }
        }