Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.94 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace ConsoleApp35
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             string inputDirection = null;
  13.             Random rand = new Random();
  14.             int currentPassenger;
  15.             int wagonCapacity = 20;
  16.             int wagonNumber;
  17.             while (true)
  18.             {
  19.                 if (inputDirection == null)
  20.                 {
  21.                     Console.SetCursorPosition(0, 0);
  22.                     Console.WriteLine("Движение поездов не осуществляется\n");
  23.                 }
  24.                 else if (inputDirection != null)
  25.                 {
  26.                     Console.SetCursorPosition(0, 0);
  27.                     Console.WriteLine($"Поезд двигается по нарвлению { inputDirection}\n");
  28.                 }
  29.                 Console.WriteLine("Введите направление поезда\n");
  30.                 inputDirection = Console.ReadLine();
  31.                 Console.Clear();
  32.                 currentPassenger = rand.Next(0, 200);
  33.                 wagonNumber = currentPassenger / wagonCapacity;
  34.                 Train train1 = new Train(inputDirection, currentPassenger, wagonNumber);
  35.                 train1.ShowInfo();
  36.             }
  37.         }
  38.     }
  39.     class Train
  40.     {
  41.         public string Direction;
  42.         public int Place;
  43.         public int WagonNumber;
  44.         public Train(string direction, int place, int wagonNumber)
  45.         {
  46.             Direction = direction;
  47.             Place = place;
  48.             WagonNumber = wagonNumber;
  49.         }
  50.         public void ShowInfo()
  51.         {
  52.             Console.SetCursorPosition(0, 1);
  53.             Console.WriteLine($"поезд из {WagonNumber} вагонов по направлению {Direction} отправлен\n");
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement