public void AddWheels(Wheel i_Wheel, int i_NumOfWheels, Wheel.eMaxAirPressure i_VehiclePressure) { for (int i = 0; i < i_NumOfWheels; i++) { i_Wheel.MaxAirPressure = (float)i_VehiclePressure; i_Wheel.CurrentAirPressure = (float)i_VehiclePressure; this.r_Wheels.Add(i_Wheel); } }
protected void InitializeWheelsList( string i_Manufacturer, eNumberOfWheels i_NumberOfWheels, Wheel.eMaxAirPressure i_MaxAirPressure, float i_CurrentAirPressure) { m_Wheels = new List <Wheel>(); for (int i = 0; i < (int)i_NumberOfWheels; i++) { Wheels.Add(new Wheel((float)i_MaxAirPressure, i_CurrentAirPressure, i_Manufacturer)); } }
private bool checkCurrentWheelAirPressure(string i_CurrentWheelAirPressure) { float currentAirPressure; bool isValidAirPressure = float.TryParse(i_CurrentWheelAirPressure, out currentAirPressure); if (!isValidAirPressure) { throw new FormatException("Failed parse: string->float"); } string vehicleType = this.GetType().Name; Wheel.eMaxAirPressure maxAirPressure = (Wheel.eMaxAirPressure)Enum.Parse(typeof(Wheel.eMaxAirPressure), vehicleType); if (currentAirPressure > (float)maxAirPressure || currentAirPressure < 0) { throw new ValueOutOfRangeException((float)maxAirPressure, 0); } return(true); }