Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Action(uint action, ref int balance, int refill = 0, int cut = 0)
- {
- switch (action)
- {
- case 1:
- Console.WriteLine();
- Console.WriteLine($"Ваш баланс = {balance} руб.");
- Console.ReadLine();
- break;
- case 2:
- Console.WriteLine();
- Console.WriteLine("На какую сумму хотите пополнить баланс?");
- Console.Write("Введите сумму: ");
- refill = int.Parse(Console.ReadLine());
- if (refill <= 0)
- {
- Console.WriteLine("Вы ввели некорректное значение!");
- Console.ReadLine();
- break;
- }
- else
- {
- balance += refill;
- break;
- }
- case 3:
- Console.WriteLine();
- Console.WriteLine("Какую сумму хотите снять с баланса?");
- Console.Write("Введите сумму: ");
- cut = int.Parse(Console.ReadLine());
- if (cut <= 0)
- {
- Console.WriteLine("Вы ввели некорректное значение!");
- Console.ReadLine();
- break;
- }
- if (balance >= cut)
- {
- balance -= cut;
- }
- else
- {
- Console.WriteLine("На балансе недостаточно средств!");
- Console.ReadLine();
- }
- break;
- default:
- Console.WriteLine();
- Console.WriteLine("Вы ввели некорректное значение!");
- break;
- }
- }
- static void Massage()
- {
- Console.WriteLine("\t========Bank========");
- Console.WriteLine();
- Console.WriteLine("\t Выберите действие:");
- Console.WriteLine("1. Узнать баланс");
- Console.WriteLine("2. Пополнить баланс");
- Console.WriteLine("3. Снять наличные");
- Console.WriteLine("4. Выход из приложения");
- Console.WriteLine();
- }
- static void Main(string[] args)
- {
- int balance = 0;
- uint action = 0;
- while (action != 4)
- {
- Massage();
- try
- {
- action = uint.Parse(Console.ReadLine());
- }
- catch (Exception)
- {
- Console.WriteLine("Вы ввели недопустимое значение!");
- Console.ReadLine();
- }
- Action(action, ref balance);
- Console.Clear();
- }
- Console.WriteLine("Для выхода из программы нажмите любую клавишу...");
- Console.ReadKey();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement