Advertisement
SomeBody_Aplle

Untitled

Mar 28th, 2021
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.80 KB | None | 0 0
  1. class Car
  2.     {
  3.         private string Name;
  4.         private string Color;
  5.         private int Price;
  6.         private bool Available;
  7.         private string InfoForFuel;
  8.  
  9.         public void Changes()
  10.         {
  11.             Console.WriteLine("Что хотите изменить в данных?");
  12.             Console.WriteLine("1.Цвет");
  13.             Console.WriteLine("2.Цену");
  14.             Console.WriteLine("3.Наличие");
  15.             Console.WriteLine("4.Информацию о топливе");
  16.             Console.Write("Выбор: ");
  17.             uint value = uint.Parse(Console.ReadLine());
  18.             Console.WriteLine();
  19.             switch (value)
  20.             {
  21.                 case 1:
  22.                     Console.Write("Введите новый цвет: ");
  23.                     Color = Console.ReadLine();
  24.                     break;
  25.                 case 2:
  26.                     Console.Write("Введите новую цену: ");
  27.                     Price = int.Parse(Console.ReadLine());
  28.                     break;
  29.                 case 3:
  30.                     Console.WriteLine("В наличии или нет?");
  31.                     Console.WriteLine();
  32.                     string a = Console.ReadLine();
  33.                     if (a == "Да")
  34.                     {
  35.                         Available = true;
  36.                         break;
  37.                     }
  38.                     if (a == "Нет")
  39.                     {
  40.                         Available = false;
  41.                         break;
  42.                     }
  43.                     break;
  44.                 case 4:
  45.                     Console.Write("Введите название нового топлива: ");
  46.                     InfoForFuel = Console.ReadLine();
  47.                     break;
  48.                 default:
  49.                     break;
  50.             }
  51.         }
  52.         public void Filling()
  53.         {
  54.             Name = "BMW i8";
  55.             Color = "Красный";
  56.             Price = 9910000;
  57.             Available = true;
  58.             InfoForFuel = "Бензин";
  59.         }
  60.  
  61.         public void Print()
  62.         {
  63.             Console.WriteLine("\tИнформация о машине");
  64.             Console.WriteLine();
  65.             Console.WriteLine($"Название: {Name}");
  66.             Console.WriteLine($"Цвет: {Color}");
  67.             Console.WriteLine($"Цена: {Price} руб");
  68.             if (Available == true)
  69.             {
  70.                 Console.WriteLine($"Наличие: На складе");
  71.             }
  72.             else
  73.             {
  74.                 Console.WriteLine($"Наличие: отсутсвует");
  75.             }
  76.             Console.WriteLine($"Вид топлива: {InfoForFuel}");
  77.         }
  78.     }
  79.  
  80.     class Program
  81.     {
  82.         static uint Massege()
  83.         {
  84.             Console.WriteLine();
  85.             Console.WriteLine("Хотите изменить какие-то данные о машине?");
  86.             Console.WriteLine("1. Да");
  87.             Console.WriteLine("2. Нет");
  88.             Console.Write("Выбор: ");
  89.             uint yesOrNo = uint.Parse(Console.ReadLine());
  90.             Console.WriteLine();
  91.             return yesOrNo;
  92.         }
  93.         static void Main(string[] args)
  94.         {
  95.             var BMW_i8 = new Car();
  96.             BMW_i8.Filling();
  97.             BMW_i8.Print();
  98.             uint yesOrNo = Massege();
  99.             if (yesOrNo == 1)
  100.             {
  101.                 switch (yesOrNo)
  102.                 {
  103.                     case 1:
  104.                         BMW_i8.Changes();
  105.                         break;
  106.                     case 2:
  107.                         break;
  108.                     default:
  109.                         break;
  110.                 }
  111.                 BMW_i8.Print();
  112.             }
  113.         }
  114.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement