Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var bancomat = new Bancomat();

            Console.WriteLine(bancomat.CashOut(1415, CurrencyType.Dollar));
            Console.WriteLine(bancomat.CashOut(2110, CurrencyType.Ruble));
            Console.WriteLine(bancomat.CashOut(1285, CurrencyType.Eur));
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var bancomat  = new Bancomat();
            var banknotes = bancomat.GiveMoney(1700, CurrencyType.Ruble);

            Console.WriteLine("Ваши наличные: ");
            foreach (var banknote in banknotes)
            {
                Console.Write(banknote + " "); // 1000 200 200 200 10 10 10 10 10 10 10 10 10 10
            }

            banknotes = bancomat.GiveMoney(121, CurrencyType.Dollar); // System.Exception: Невозможно выдать данную сумму
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            var bancomat_ru    = new Bancomat(CurrencyType.Ruble);
            var firstBanknotes = bancomat_ru.WithdrawСash(2050, CurrencyType.Ruble);

            var bancomat_en      = new Bancomat(CurrencyType.Dollar);
            var secondBanknotest = bancomat_en.WithdrawСash(2140, CurrencyType.Dollar);


            foreach (var banknote in firstBanknotes)
            {
                Console.WriteLine(banknote + "руб." + " ");
            }

            foreach (var banknote in secondBanknotest)
            {
                Console.WriteLine(banknote + "$" + " ");
            }
        }
Exemplo n.º 4
0
        private static void ExecuteExample()
        {
            Console.ForegroundColor = ConsoleColor.DarkGray;
            PrintDebug();
            var bancomat = new Bancomat();

            PrintDebug();
            Console.ResetColor();

            try
            {
                Console.WriteLine("Введите валюту целым положительным числом:");

                var currencies = Enum.GetNames(typeof(CurrencyType));
                for (int i = 0; i < currencies.Length; i++)
                {
                    Console.WriteLine($"{i} - {currencies[i]}");
                }

                var currencyInt = int.Parse(Console.ReadLine());
                if (currencyInt < 0 || currencyInt >= currencies.Length)
                {
                    throw new Exception("Валюта введена неправильно.");
                }

                Console.WriteLine("Введите сумму целыи неотрицательным числом:");

                var amountOfMoney = int.Parse(Console.ReadLine());
                var banknotes     = bancomat.GetCash((CurrencyType)currencyInt, amountOfMoney);

                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(string.Join("; ", banknotes.Select(b => b.ToString())));
                Console.ResetColor();
            }
            catch (Exception exception)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(exception.Message);
                Console.ResetColor();
            }
        }