public Car(eCarColor i_CarColor, eCarDoors i_NumOfDoors, List <Tire> i_Tires, Powersource i_Powersource, string i_LicensePlate, string i_ModelName) : base(i_LicensePlate, i_ModelName) { m_Tires = i_Tires; m_Powersource = i_Powersource; m_CarColor = i_CarColor; r_NumOfDoors = i_NumOfDoors; }
public static Dictionary <eVehicleInfoParams, ParameterValidator> BuildExtraParameters() { StringBuilder strToPrint = new StringBuilder(); eCarColors carColor = eCarColors.BLACK; eCarDoors carDoors = eCarDoors.FIVE; Dictionary <eVehicleInfoParams, ParameterValidator> keyValues = new Dictionary <eVehicleInfoParams, ParameterValidator>(); strToPrint.AppendLine("Please enter your car color: "); strToPrint.Append(StringUtils.GetEnumListAsString(carColor)); keyValues.Add(eVehicleInfoParams.carColor, new ParameterValidator(strToPrint.ToString(), ParameterValidator.eValidityTypes.CarColor)); strToPrint.Clear(); strToPrint.AppendLine("Please enter your number of doors: "); strToPrint.Append(StringUtils.GetEnumListAsString(carDoors)); keyValues.Add(eVehicleInfoParams.carDoors, new ParameterValidator(strToPrint.ToString(), ParameterValidator.eValidityTypes.DoorNumber)); return(keyValues); }
public void UpdateNewCarInput(int i_CarColor, int i_AmountOfDoors) { switch (i_AmountOfDoors) { case 2: m_AmountOfDoors = eCarDoors.TWO; break; case 3: m_AmountOfDoors = eCarDoors.THREE; break; case 4: m_AmountOfDoors = eCarDoors.FOUR; break; case 5: m_AmountOfDoors = eCarDoors.FIVE; break; } switch (i_CarColor) { case 1: m_CarColor = eCarColor.Red; break; case 2: m_CarColor = eCarColor.Blue; break; case 3: m_CarColor = eCarColor.Grey; break; case 4: m_CarColor = eCarColor.Black; break; } }
public static void CheckInputParameterValid(string i_InputString, eValidityTypes i_ValidityType) { eCarDoors carDoors = eCarDoors.FIVE; eCarColors carColors = eCarColors.BLACK; eLicenseType licenseType = eLicenseType.A; switch (i_ValidityType) { case eValidityTypes.All: break; case eValidityTypes.LettersOnly: StringUtils.CheckStringConsistsOnlyLetters(i_InputString); break; case eValidityTypes.NumberOnly: StringUtils.CheckStringConsistsOnlyNumbers(i_InputString); break; case eValidityTypes.Boolean: StringUtils.CheckStringRepresentBool(i_InputString); break; case eValidityTypes.CarColor: checkEnumChoiceIsValid(i_InputString, carColors); break; case eValidityTypes.DoorNumber: checkEnumChoiceIsValid(i_InputString, carDoors); break; case eValidityTypes.LicenseType: checkEnumChoiceIsValid(i_InputString, licenseType); break; default: throw new ArgumentOutOfRangeException(nameof(i_ValidityType), i_ValidityType, null); } }
private static Vehicle createCar(Engine i_Engine, Dictionary <eVehicleInfoParams, string> i_VehicleParameters) { string modelName; string licenseNumber; float energyPercentageLeft; string wheelManufactureName; float wheelCurrentAirPressure; eCarColors carColor = (eCarColors)Enum.Parse(typeof(eCarColors), i_VehicleParameters[eVehicleInfoParams.carColor]); eCarDoors carDoors = (eCarDoors)Enum.Parse(typeof(eCarDoors), i_VehicleParameters[eVehicleInfoParams.carDoors]); getVehicleParameters( i_VehicleParameters, out modelName, out licenseNumber, out energyPercentageLeft, out wheelManufactureName, out wheelCurrentAirPressure); Car car = new Car(carColor, carDoors, modelName, licenseNumber, energyPercentageLeft, new Wheel[Car.k_NumOfWheels], i_Engine, wheelManufactureName, wheelCurrentAirPressure, Car.k_MaxAirPressure); return(car); }
public ElectricCar(string i_ModelName, string i_LicensePlate, eColor i_Color, eCarDoors i_Doors, string i_Manufacture) : base(i_ModelName, i_LicensePlate, i_Color, i_Doors, new ElectricEnergy(k_MaxBatteryCapacity), i_Manufacture) { }
public Car(eCarColors i_CarsColor, eCarDoors i_AmountOfDoors, string i_ModelName, string i_LicensingNumber, float i_LeftEnergy, Wheel[] i_Wheels, Engine i_Engine, string i_ManufacturerName, float i_CurrAirPressure, float i_MaxAirPressure) : base(i_ModelName, i_LicensingNumber, i_LeftEnergy, i_Wheels, i_Engine, i_ManufacturerName, i_CurrAirPressure, i_MaxAirPressure) { m_CarColor = i_CarsColor; m_AmountOfDoors = i_AmountOfDoors; }
public static bool CheckProperty(Garage i_Garage, string i_Value, string i_Field, string i_Type) { bool boolField = false; string stringField = ""; float floatField = 0; int intField = 0; eCarDoors doorField = eCarDoors.Five; eColor colorField = eColor.Black; eLicenseType licenseTypeField = eLicenseType.A; string colorError = "This Field must be one of those: " + String.Join(" / ", Enum.GetNames(typeof(eColor)).ToList().Select(x => x.ToString())); string carDoorError = "This Field must be one of those: " + String.Join(" / ", Enum.GetNames(typeof(eCarDoors)).ToList().Select(x => x.ToString())); string licenseTypeError = "This Field must be one of those: " + String.Join(" / ", Enum.GetNames(typeof(eLicenseType)).ToList().Select(x => x.ToString())); switch (i_Type) { case "int": intField = !int.TryParse(i_Value, out intField) ? throw new FormatException("This Field must be a number") : intField < 0 ? throw new FormatException("Positive number only") : intField; break; case "eColor": colorField = !Enum.IsDefined(typeof(eColor), i_Value) ? throw new FormatException(colorError) : colorField; break; case "eCarDoors": doorField = !Enum.IsDefined(typeof(eCarDoors), i_Value) ? throw new FormatException(carDoorError) : doorField; break; case "eLicenseType": licenseTypeField = !Enum.IsDefined(typeof(eLicenseType), i_Value) ? throw new FormatException(licenseTypeError) : licenseTypeField; break; case "bool": boolField = !bool.TryParse(i_Value, out boolField) ? throw new FormatException("This Field must be a True of False") : boolField; break; case "float": floatField = !float.TryParse(i_Value, out floatField) ? throw new FormatException("This Field must be a float") : floatField < 0 ? throw new FormatException("Positive number only") : floatField; break; case "string": if (i_Field == "License Plate") { if (i_Garage.IsLicensePlateExists(i_Value)) { throw new ArgumentException("There is already a Vehicle with the same license plate"); } } if (i_Value.Replace(" ", "").Length == 0) { throw new FormatException("This Field can't be empty"); } break; } return(true); }
public static Vehicle CreateNewVehicle(Garage i_Garage, eVehicleTypes vehicleType, Dictionary <string, string> i_Properties) { Vehicle i_Vehicle; bool creationSuccess = false; string modelName = "", licensePlate = "", manufacture = ""; float engineCapacity = 0, loadVolume = 0; bool isCarryingDangerousLoad = false; eCarDoors door = eCarDoors.Five; eColor color = eColor.Black; eLicenseType licenseType = eLicenseType.A; foreach (KeyValuePair <string, string> pairs in i_Properties) { switch (pairs.Key) { case "Model Name": modelName = pairs.Value; break; case "License Plate": licensePlate = pairs.Value; break; case "Manufacture": manufacture = pairs.Value; break; case "Car Color": eColor.TryParse(pairs.Value, out color); break; case "Number of Doors": eCarDoors.TryParse(pairs.Value, out door); break; case "Engine Capacity CCS": engineCapacity = float.Parse(pairs.Value); break; case "License Type": eLicenseType.TryParse(pairs.Value, out licenseType); break; case "Is carrying dangerous load": isCarryingDangerousLoad = bool.Parse(pairs.Value); break; case "Load Volume": loadVolume = float.Parse(pairs.Value); break; } } switch (vehicleType) { case eVehicleTypes.ElectronicCar: i_Vehicle = new ElectricCar(modelName, licensePlate, color, door, manufacture); //ElectricCar.TryParse(i_Properties, out newVehicle); break; case eVehicleTypes.ElectronicMotorCycle: i_Vehicle = new ElectricMotorCycle(modelName, licensePlate, engineCapacity, eLicenseType.A1, manufacture); break; case eVehicleTypes.FuelCar: i_Vehicle = new FuelCar(modelName, licensePlate, color, door, manufacture); //FuelCar.TryParse(i_Properties, out newVehicle); break; case eVehicleTypes.FuelMotorCycle: i_Vehicle = new FuelMotorCycle(modelName, licensePlate, engineCapacity, licenseType, manufacture); break; case eVehicleTypes.Truck: i_Vehicle = new Truck(modelName, licensePlate, manufacture, isCarryingDangerousLoad, loadVolume); break; default: i_Vehicle = null; break; } return(i_Vehicle); }
public Car(string i_ModelName, string i_LicensePlate, eColor i_Color, eCarDoors i_NumberOfDoors, VehicleEnergy i_VehicleEnergy, string i_Manufacture) : base(i_ModelName, i_LicensePlate, i_VehicleEnergy, k_HowManyTires, k_MaxTirePressure, i_Manufacture) { m_Color = i_Color; m_NumberOfDoors = i_NumberOfDoors; }
public FuelCar(string i_ModelName, string i_LicensePlate, eColor i_Color, eCarDoors i_Doors, string i_Manufacture) : base(i_ModelName, i_LicensePlate, i_Color, i_Doors, new FuelEnergy(k_FuelType, k_MaxAmountOfFuel), i_Manufacture) { }