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