private Vehicle createVehicle(CreatingVehicles.eTypeOfVehicles i_TypeOfVehicle) { CreatingVehicles vehiclesMaker = new CreatingVehicles(i_TypeOfVehicle); Vehicle vehicleToAdd = vehiclesMaker.CreateVehicle(); StringBuilder askForData = vehicleToAdd.AskForData; string[] splitAskForData = askForData.ToString().Split('\n'); List <int> enumable = getEnumableProperties(splitAskForData[splitAskForData.Length - 2]); string[] storeData = new string[splitAskForData.Length - 2]; for (int i = 0; i < storeData.Length; i++) { if (enumable.Contains(i)) { Type getType = getVehicleTypeOfEnum(i_TypeOfVehicle); PrintingUtils.PrintListOfEnum(splitAskForData[i], getType); storeData[i] = Console.ReadLine(); } else { Console.WriteLine(splitAskForData[i]); storeData[i] = Console.ReadLine(); } } vehicleToAdd.SetVehicleData = storeData; return(vehicleToAdd); }
private Type getVehicleTypeOfEnum(CreatingVehicles.eTypeOfVehicles i_TypeOfVehicle) { Type type; if (i_TypeOfVehicle.Equals(CreatingVehicles.eTypeOfVehicles.ElectricCar) || i_TypeOfVehicle.Equals(CreatingVehicles.eTypeOfVehicles.FuelCar)) { type = typeof(CarData.eColor); } else { type = typeof(MotorcycleData.eLicenseType); } return(type); }