Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace FifthProject
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] tables = { 2, 2, 4, 6, 8 };
- int[] maxTables = { 2, 2, 4, 6, 8};
- int userChange;
- int userTable;
- int userPlace;
- while (true)
- {
- Console.WriteLine("Добро пожаловать в систему брони.");
- for (int i = 0; i < tables.Length; i++)
- {
- Console.WriteLine($"Стол {i + 1} - свободно {tables[i]}");
- }
- Console.WriteLine("\n1. Забронировать стол \n2. Отменить бронь \n3. Выход");
- userChange = Convert.ToInt32(Console.ReadLine());
- if (userChange == 1)
- {
- Console.Write("\nКакой вам нужен стол:");
- userTable = Convert.ToInt32(Console.ReadLine()) - 1;
- if (userTable >= 0 && userTable < tables.Length)
- {
- Console.Write("\nСколько вам нужно мест:");
- userPlace = Convert.ToInt32(Console.ReadLine());
- if (userPlace > 0 && userPlace <= tables[userTable])
- {
- tables[userTable] -= userPlace;
- }
- else
- {
- Console.WriteLine("Не корректный ввод");
- }
- }
- else
- {
- Console.WriteLine("Несуществующий стол");
- }
- }
- else if (userChange == 2)
- {
- Console.Write("\nКакой вам нужен стол:");
- userTable = Convert.ToInt32(Console.ReadLine()) - 1;
- if (userTable >= 0 && userTable < tables.Length)
- {
- Console.Write("\nСколько вам нужно вернуть мест:");
- userPlace = Convert.ToInt32(Console.ReadLine());
- if (userPlace >= 0 && userPlace <= maxTables[userTable])
- {
- if (tables[userTable] + userPlace <= maxTables[userTable])
- {
- tables[userTable] += userPlace;
- }
- else
- {
- tables[userTable] = maxTables[userTable];
- }
- }
- else
- {
- Console.WriteLine("Не корректный ввод");
- }
- }
- else
- {
- Console.WriteLine("Несуществующий стол");
- }
- }
- else if ( userChange == 3)
- {
- break;
- }
- else
- {
- Console.WriteLine("Не корректный ввод!");
- Console.ReadKey();
- }
- Console.Clear();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement