public void AddNewCar() { string name; string color; int speed; int year; Console.Write("\nEnter a name of car: "); name = Console.ReadLine(); Console.Write("Enter a color of car: "); color = Console.ReadLine(); Console.Write("Enter a car`s speed: "); while (!int.TryParse(Console.ReadLine(), out speed) || speed <= 0) { Console.Write("Enter a correct speed value, please: "); } Console.Write("Enter a car`s year of issue: "); while (!int.TryParse(Console.ReadLine(), out year) || year > 2019 || year < 1900) { Console.Write("Enter a correct year, please: "); } car newCar = new car(name, color, speed, year); myCars.Add(newCar); }
public void DisplayInfoAboutCar(car car) { Console.WriteLine("\nName : {0}\nColor : {1}\nSpeed : {2}\nYear : {3}", car.Name, car.Color, car.Speed, car.YearOfIssue); }