public CarOptions GetOrder() { CarOptions newCar = new CarOptions(); Console.WriteLine("Enter the options you are interested in otherwise, type -"); Console.WriteLine("Enter brand"); newCar.Brand = Console.ReadLine(); Console.WriteLine("Enter model"); newCar.Model = Console.ReadLine(); Console.WriteLine("Enter type of body (estate, sedan, minivan, coupe);"); newCar.CarcaseType = Console.ReadLine(); Console.WriteLine("Enter type of transmission (manual, automatic);"); newCar.TransmissionType = Console.ReadLine(); Console.WriteLine("Enter type of engine (gasoline, diesel, electro);"); newCar.EngineType = Console.ReadLine(); Console.WriteLine("Enter volume"); newCar.EngineSize = Console.ReadLine(); Console.WriteLine("Enter power"); newCar.EnginePower = Console.ReadLine(); Console.WriteLine("Enter climate control: air conditioning, climate control, -"); newCar.ClimateControle = Console.ReadLine(); Console.WriteLine("Enter type of interior (leather, fabric, combined)"); newCar.CabinType = Console.ReadLine(); return(newCar); }
public ICar MakeCar(CarOptions carOptions = null) { Car car = new Car(); car.SetPrice(carOptions?.Price == null ? 0 : carOptions.Price); car.SetColor(String.IsNullOrEmpty(carOptions?.Color) ? "N/A" : carOptions.Color); car.SetSafetyRating(carOptions?.SafetyRating == null ? 0 : carOptions.SafetyRating); car.SetOptions(carOptions?.OtherOptions); return(car); }
public void GiveSuitableMachines() { CarOptions carOptions = carOptionsReader.GetOrder(); Console.WriteLine("Suitable machines is:"); IEnumerable <CarOptions> cars = CheckCarStorage(carOptions); foreach (CarOptions car in cars) { car.GetOptionsToConsole(); } }
private IEnumerable <CarOptions> CheckCarStorage(CarOptions carOptions) { List <CarOptions> catalog = carsCatalog.GetCatalog(); var selectedVariants = from item in catalog where ((item.Brand == carOptions.Brand) && (item.Model == carOptions.Model || item.Model == "-") && (item.CarcaseType == carOptions.CarcaseType || item.Model == "-") && (item.TransmissionType == carOptions.TransmissionType || item.Model == "-") && (item.EngineType == carOptions.EngineType || item.Model == "-") && (item.EngineSize == carOptions.EngineSize || item.Model == "-") && (item.EnginePower == carOptions.EnginePower || item.Model == "-") && (item.ClimateControle == carOptions.ClimateControle || item.Model == "-") && (item.CabinType == carOptions.CabinType || item.Model == "-")) select item; return(selectedVariants); }
public void AddToCatalog(CarOptions car) { Cars.Add(car); carsJson = JsonConvert.SerializeObject(Cars); File.WriteAllText(pathToJsonFileWithCars, carsJson); }