Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- Queue<int> buyers = new Queue<int>();
- int storeAccount = 0;
- AddChecks(buyers);
- bool isSale = true;
- Console.Clear();
- while (isSale)
- {
- if (buyers.Count > 0)
- {
- ServeCustomer(buyers, storeAccount);
- }
- else
- {
- isSale = false;
- Console.WriteLine("Спасибо что воспользовались нашим магазином! Досвидания.");
- Console.ReadKey();
- }
- }
- }
- static void AddChecks(Queue<int> buyers)
- {
- string checkAmount;
- int lengthCollection = 4;
- Console.WriteLine($"Введите {lengthCollection} цифр готовых чеков.");
- while (int.TryParse(checkAmount = Console.ReadLine(), out int amountPurchase) == false || buyers.Count < lengthCollection)
- {
- buyers.Enqueue((int)amountPurchase);
- }
- }
- static void ShowQueue(Queue<int> buyers)
- {
- Console.Clear();
- Console.CursorVisible = false;
- Console.SetCursorPosition(0, 2);
- foreach (var item in buyers)
- {
- Console.WriteLine(item);
- }
- }
- static int ServeCustomer(Queue<int> buyers, int storeAccount)
- {
- const ConsoleKey CommandСontinueCounting = ConsoleKey.Enter;
- string commanContinue = "Ввод";
- while (buyers.Count > 0)
- {
- Console.WriteLine($"Для продолжения обслуживания нажмите \'{commanContinue}\'");
- ConsoleKeyInfo exit = Console.ReadKey();
- ShowQueue(buyers);
- if (exit.Key == CommandСontinueCounting)
- {
- storeAccount += buyers.Dequeue();
- }
- UpdateAccountOfStore(storeAccount);
- }
- return storeAccount;
- }
- static void UpdateAccountOfStore(int totalAmountPurchases)
- {
- Console.SetCursorPosition(30, 3);
- Console.WriteLine($"Общий счет магазина {totalAmountPurchases}.");
- Console.SetCursorPosition(0, 0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement