コード例 #1
0
        public float Withdraw()
        {
            BankDetails details = new BankDetails();

            BankAccount.Comision c = Comission.Comision;

            string      iban    = rv.EnterIban();
            BankAccount account = rv.GetAccountByName(iban, _accounts);

            while (account == null)
            {
                Console.WriteLine("Account doesn't exist");
                iban    = rv.EnterIban();
                account = rv.GetAccountByName(iban, _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, iban);
            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);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: ae2021/csharp1
        public static void App()
        {
            BankDetails bankdet = new BankDetails();

            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;
                }
            }
        }