private VehicleCreator.eVehicleTypes letUserChooseCarOption() { VehicleCreator.eVehicleTypes userOption = 0; string[] VehicleTypes = Enum.GetNames(typeof(VehicleCreator.eVehicleTypes)); Console.WriteLine("Please choose One of the following options by its corresponding number or any other value for none of them"); for (int index = 1; index <= VehicleTypes.Length; index++) { Console.Write(index + "."); printSpacelessPhraseByUppercase(VehicleTypes[index - 1]); } userOption = (VehicleCreator.eVehicleTypes)Enum.Parse(typeof(VehicleCreator.eVehicleTypes), Console.ReadLine()); return(userOption); }
public static Vehicle CreateVehicle(VehicleCreator.eVehicleTypes chosenVehicleOption) { Vehicle createdVehicle = null; switch (chosenVehicleOption) { case eVehicleTypes.ElectricCar: { createdVehicle = new Car(v_Electric); break; } case eVehicleTypes.PetrolCarWithOctan95: { createdVehicle = new Car(v_Petrol); break; } case eVehicleTypes.PetrolMotorbikeWithOctan98: { createdVehicle = new Motorbike(v_Petrol); break; } case eVehicleTypes.ElectricMotorbike: { createdVehicle = new Motorbike(v_Electric); break; } case eVehicleTypes.TruckWithSoler: { createdVehicle = new Truck(v_Petrol); break; } } return(createdVehicle); }
private void enterNewVehicle(GarageLogicManager i_GarageInstance) { bool codeSectionCompleted = false; VehicleCreator.eVehicleTypes chosenVehicleOption = letUserChooseCarOption();; if (Enum.IsDefined(typeof(VehicleCreator.eVehicleTypes), chosenVehicleOption)) { Console.WriteLine("Please enter vehicle serial:"); string carSerialInput = Console.ReadLine(); Vehicle toEnterVehicle = null; if (i_GarageInstance.GarageDictionary.TryGetValue(carSerialInput, out toEnterVehicle)) { } else { toEnterVehicle = VehicleCreator.CreateVehicle(chosenVehicleOption); i_GarageInstance.GarageDictionary.Add(carSerialInput, toEnterVehicle); } setBaseProperties(toEnterVehicle, carSerialInput); setRequiredInputs(toEnterVehicle); } }