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 ConsoleApp35
- {
- class Program
- {
- static void Main(string[] args)
- {
- string inputDirection = null;
- Random rand = new Random();
- int currentPassenger;
- int wagonCapacity = 20;
- int wagonNumber;
- while (true)
- {
- if (inputDirection == null)
- {
- Console.SetCursorPosition(0, 0);
- Console.WriteLine("Движение поездов не осуществляется\n");
- }
- else if (inputDirection != null)
- {
- Console.SetCursorPosition(0, 0);
- Console.WriteLine($"Поезд двигается по нарвлению { inputDirection}\n");
- }
- Console.WriteLine("Введите направление поезда\n");
- inputDirection = Console.ReadLine();
- Console.Clear();
- currentPassenger = rand.Next(0, 200);
- wagonNumber = currentPassenger / wagonCapacity;
- Train train1 = new Train(inputDirection, currentPassenger, wagonNumber);
- train1.ShowInfo();
- }
- }
- }
- class Train
- {
- public string Direction;
- public int Place;
- public int WagonNumber;
- public Train(string direction, int place, int wagonNumber)
- {
- Direction = direction;
- Place = place;
- WagonNumber = wagonNumber;
- }
- public void ShowInfo()
- {
- Console.SetCursorPosition(0, 1);
- Console.WriteLine($"поезд из {WagonNumber} вагонов по направлению {Direction} отправлен\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement