//-----------------------------------------------------------------// private Exception findExceptionsInAnswers(List <string> i_Answers, out int o_LicenseType, out int o_EngineVolume) { Exception exception = null; o_LicenseType = o_EngineVolume = -1; if (!int.TryParse(i_Answers[0], out o_LicenseType)) { exception = new FormatException("Format of input of the license type isn't valid, please try again: "); exception.Source = "0"; } else if (ValueOutOfRangeException.ValueOutOfRange(o_LicenseType, 4, 1)) { exception = new ValueOutOfRangeException(4, 1, "License type for the motorcycle is out of range, please try again: ", exception); exception.Source = "0"; } if (!int.TryParse(i_Answers[1], out o_EngineVolume)) { exception = new FormatException("Format of input engine volume isn't valid, please try again: ", exception); exception.Source = "1"; } else if (ValueOutOfRangeException.ValueOutOfRange(o_EngineVolume, 1500, 1)) { exception = new ValueOutOfRangeException(1500, 1, "Engine volume for the motorcycle is out of range, please try again: "); exception.Source = "1"; } return(exception); }
//-----------------------------------------------------------------// private Exception findExceptionsInAnswers(List <string> i_Answers, out int o_ColorChoice, out int o_AmountOfDoors) { Exception exception = null; o_ColorChoice = o_AmountOfDoors = -1; if (!int.TryParse(i_Answers[0], out o_ColorChoice)) { exception = new FormatException("Format of input of the color isn't valid, please try again: "); exception.Source = "0"; } else if (ValueOutOfRangeException.ValueOutOfRange(o_ColorChoice, 4, 1)) { exception = new ValueOutOfRangeException(4, 1, "Color choice for the car is out of range, please try again: ", exception); exception.Source = "0"; } if (!int.TryParse(i_Answers[1], out o_AmountOfDoors)) { exception = new FormatException("Format of input of the number of doors isn't valid, please try again: ", exception); exception.Source = "1"; } else if (ValueOutOfRangeException.ValueOutOfRange(o_AmountOfDoors, 5, 2)) { exception = new ValueOutOfRangeException(5, 1, "Number of doors for the car is out of range, please try again: ", exception); exception.Source = "1"; } return(exception); }