コード例 #1
0
/*
 * 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);
    }
}
コード例 #2
0
ファイル: temperature.cpp プロジェクト: outreach11/CSCI21
  Temperature::Temperature(double temp, char unit){

	if (unit == 'F' || unit == 'f') {
		SetTempFromFahrenheit(temp);
	
	}
	else if (unit == 'C' || unit == 'c') {
		SetTempFromCelsius(temp);
	
	}
	else {

		SetTempFromKelvin(temp);
	
	}
		
}