示例#1
0
        static void Main(string[] args)
        {
            Bank <Account> bank = new Bank <Account>("GoldBank");
            DateTime       date = new DateTime();

            date = DateTime.Today;
            Console.WriteLine($"Добро пожаловать в {bank.Name}.\n");
            bool alive = true;

            while (alive)
            {
                ConsoleColor color = Console.ForegroundColor;
                // Работа с датой
                Console.WriteLine($"Текущий день: {date:d}");
                // Проверка 30-ти дневного периода
                foreach (var acc in bank)
                {
                    Account accaunt = (Account)acc;
                    if (CheckThirtyDayPeriod(accaunt, date))
                    {
                        Console.WriteLine($"Аккаунт {accaunt.Id}: Тридцатидневный период завершен.");
                        accaunt.Calculate(date);
                    }
                }
                //
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.WriteLine("1. Открыть счет \t 3. Вывести средства  \t 5. Настройка даты \t 7. Выйти из программы");
                Console.WriteLine("2. Закрыть счет \t 4. Пополнить счёт \t 6. Список всех аккаунтов");
                Console.Write("Введите номер пункта: ");
                Console.ForegroundColor = color;
                try
                {
                    int command = Convert.ToInt32(Console.ReadLine());

                    switch (command)
                    {
                    case 1:
                        OpenAccount(bank);
                        break;

                    case 2:
                        CloseAccount(bank);
                        break;

                    case 3:
                        Withdraw(bank);
                        break;

                    case 4:
                        Put(bank);
                        break;

                    case 5:
                        SetDate(ref date);
                        break;

                    case 6:
                        ShowAllAccounts(bank);
                        break;

                    case 7:
                        alive = false;
                        continue;
                    }
                }
                catch (Exception ex)
                {
                    // выводим сообщение об ошибке
                    color = Console.ForegroundColor;
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(ex.Message);
                    Console.ForegroundColor = color;
                }
                finally
                {
                    Console.WriteLine("Нажмите любую клавишу для продолжения...");
                    Console.ReadKey();
                    Console.Clear();
                }
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            string operation = "";

            do
            {
                Console.Write("HELLO, What Would You Like To Do Today: \n" +
                              "\n1. Register to be a new customer of the bank and open a new account - SELECT 1\n" +
                              "2. Make a Withdrawal - SELECT 2\n" +
                              "3. Make a Deposit - SELECT 3\n" +
                              "4. Print your customer and account/s details - SELECT 4\n" +
                              "5. Create a new account (for registered customers)- SELECT 5\n" +
                              "6. FOR EMPLOYEES ONLY: Print All Customers and their accounts Details - PRESS 6\n" +
                              "YOUR ANSWER:  ");

                string choice     = Console.ReadLine();
                string idNumber   = " ";
                string accountNum = " ";
                string amount     = " ";

                switch (choice)
                {
                case "1":
                {
                    Console.Write("Please Enter Your ID number (9 Digits): ");
                    idNumber = Console.ReadLine();
                    Bank.AddNewCustomer(idNumber);
                    break;
                }

                case "2":
                {
                    Console.Write("Please enter your ID Number: ");
                    idNumber = Console.ReadLine();
                    Console.Write("Please enter your Account Number: ");
                    accountNum = Console.ReadLine();
                    Console.Write("Please enter the Amount you would like to withdraw: ");
                    amount = (Console.ReadLine());
                    Bank.Withdraw(accountNum, idNumber, amount);
                    break;
                }

                case "3":
                {
                    Console.Write("Please enter your ID Number: ");
                    idNumber = Console.ReadLine();
                    Console.Write("Please enter your Account Number: ");
                    accountNum = Console.ReadLine();
                    Console.Write("Please enter the Amount you would like to deposit: ");
                    amount = (Console.ReadLine());
                    Bank.Deposit(accountNum, idNumber, amount);
                    break;
                }

                case "4":
                {
                    Console.Write("Please enter your ID Number: ");
                    idNumber = Console.ReadLine();
                    Console.Write("Please enter your Account Number: ");
                    accountNum = Console.ReadLine();
                    Console.WriteLine();
                    CustomerDetails.PrintDetails(idNumber, accountNum);
                    break;
                }

                case "5":
                {
                    Console.Write("Please enter your ID Number: ");
                    idNumber = Console.ReadLine();
                    Bank.CreateNewAccount(idNumber);
                    break;
                }

                case "6":
                {
                    Console.Write("Enter your Password: "******"OPERATION INVALID. Please select a valid operation from the main menu.");
                    break;
                }

                Console.WriteLine();
                Console.Write("If You want to do another operation press ENTER: ");
                operation = Console.ReadLine();
                Console.Clear();
            } while (String.IsNullOrWhiteSpace(operation));

            Console.WriteLine("Bye Bye, Thank you for using our Bank Application!");
        }