public static Car.Fuel EnterFuelType() { int fuel = 0; do { Console.Write("Druh paliva: 1 - benzin / 2 - diesel / 3 - hybrid / 4 - plyn / 5 - elektro: "); isCorrectInput = int.TryParse(Console.ReadLine(), out fuel) && (fuel >= 1 && fuel <= 5); if (!isCorrectInput) { Console.WriteLine("Zadana nespravna hodnota. Vyberte si z moznosti 1 - 5 "); } }while (!isCorrectInput); Car.Fuel fuelType = (Car.Fuel)fuel - 1; return(fuelType); }
public static void AddCar() { Console.WriteLine("Zadaj parametre auta"); int id = MaxId + 1; int manufactureYear = EnterManufactureYear(); int km = EnterKm(); string brand = EnterBrand(); string type = EnterType(); Car.Fuel fuelType = EnterFuelType(); decimal price = EnterPrice(); string cityOfSale = EnterCityOfSale(); int doorCount = EnterDoorCount(); bool isCrashed = EnterIsCrashed(); Car car = new Car(id, manufactureYear, km, brand, type, fuelType, price, cityOfSale, doorCount, isCrashed); cars.Add(car); Console.WriteLine("Auto bolo pridane."); MaxId++; }