Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace AutoService
- {
- class Program
- {
- static void Main(string[] args)
- {
- Service service = new Service();
- service.GetDetails();
- service.CreateQueue();
- service.Work();
- }
- }
- class Service
- {
- public int Balance { get; private set; }
- public int WorkCost { get; private set; }
- public int Penalty { get; private set; }
- private List<Detail> details = new List<Detail>();
- private Queue<Client> queueLine = new Queue<Client>();
- public Service()
- {
- Balance = 0;
- WorkCost = 200;
- Penalty = 300;
- List<Detail> details = new List<Detail>();
- Queue<Client> queueLine = new Queue<Client>();
- }
- public void CreateQueue()
- {
- for (int i = 0; i < 12; i++)
- {
- Client newClient = new Client();
- queueLine.Enqueue(newClient);
- }
- }
- public void GetDetails()
- {
- for (int i = 0; i < 15; i++)
- {
- Detail newDetail = new Detail();
- details.Add(newDetail);
- }
- }
- public void ShowAllDetails()
- {
- int i = 1;
- foreach (var item in details)
- {
- Console.WriteLine($"[{i}] - деталь размера: {item.Size}");
- i++;
- }
- }
- public void ReplaceDetail(int number, Client client)
- {
- if (details[number - 1].Size == client.ShowProblem())
- {
- Balance += details[number - 1].Price + WorkCost;
- details.RemoveAt(number - 1);
- Console.WriteLine("Деталь успешно заменена!");
- }
- else
- {
- Balance -= Penalty;
- Console.WriteLine("Выбрана неподходящая деталь, выплачен штраф.");
- }
- }
- public void Work()
- {
- while (queueLine.Count > 0)
- {
- Console.WriteLine("Auto-Service Balance - " + Balance);
- var currentClient = queueLine.Dequeue();
- currentClient.ShowProblem();
- ShowAllDetails();
- Console.WriteLine("Заменить деталь?\n1 - Yes\n2 - No");
- int userChoice = Convert.ToInt32(Console.ReadLine());
- if (userChoice == 1)
- {
- Console.WriteLine("\nВведите номер детали со склада?");
- userChoice = Convert.ToInt32(Console.ReadLine());
- ReplaceDetail(userChoice, currentClient);
- }
- else
- {
- Balance -= Penalty;
- Console.WriteLine("Клиенту отказано в ремонте, выплачен штраф. Нажмите ввод, чтобы продолжить.");
- Console.ReadKey();
- }
- Console.Clear();
- }
- Console.WriteLine("Рабочий день окончен! Денег в кассе - " + Balance);
- }
- }
- class Detail
- {
- public int Size { get; private set; }
- public int Price { get; private set; }
- public Detail()
- {
- Random rand = new Random();
- Size = rand.Next(1, 10);
- Price = rand.Next(100, 300);
- }
- }
- class Client
- {
- public int Money { get; private set; }
- public Detail BrokenDetail { get; private set; }
- public Client()
- {
- Money = 1000;
- Detail brokenDetail = new Detail();
- BrokenDetail = brokenDetail;
- }
- public void Pay(int sum)
- {
- Money -= sum;
- }
- public int ShowProblem()
- {
- Console.WriteLine("Сломана деталь размера - " + BrokenDetail.Size);
- return BrokenDetail.Size;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement