/* * Constructor #3. * Converts the supplied temperature to kelvin and internally stores it. * The temperature's unit will be provided in the second argument. * If the second argument is not value (i.e. not 'F' or 'C') assume the * temperature is in kelvin * @param double temp - The value to set the internal kelvin to once * - converted. * @param char unit - The type of unit temp is. Will be either 'F' or 'C', * case-insensitive */ Temperature::Temperature(double temp, char unit) { if(toupper(unit)=='F') { SetTempFromFahrenheit(temp); } else if(toupper(unit)=='C') { SetTempFromCelsius(temp); } else { SetTempFromKelvin(temp); } }
Temperature::Temperature(double temp, char unit){ if (unit == 'F' || unit == 'f') { SetTempFromFahrenheit(temp); } else if (unit == 'C' || unit == 'c') { SetTempFromCelsius(temp); } else { SetTempFromKelvin(temp); } }