java.lang.Object | +--TemperatureReading4
This class encapsulates the data from a temperature reading. The details of how a temperature is stored are hidden from the user of objects created from this class. The public interface of this class requires that the scale of a temperature must always be specified. This provides a safe way to store temperature values.
Field Summary | |
static double |
BOILING_C
|
static double |
BOILING_F
|
static double |
FREEZING_C
|
static double |
FREEZING_F
|
Constructor Summary | |
TemperatureReading4(char scale,
double temperature,
double latitude,
double longitude)
A constructor that specifies a scale for the temperature. |
Method Summary | |
static double |
convertCtoF(double degreesC)
A static method that converts numbers from a Celsius value to a Fahrenheit value. |
static double |
convertFtoC(double degreesF)
A static method that converts numbers from a Fahrenheit value to a Celsius value. |
double |
getLatitude()
Retrieve the latitude of where the temperature reading was made. |
double |
getLongitude()
Retrieve the longitude of where the temperature reading was made. |
double |
getTemperatureC()
Retrieve the temperature value using the Celsius scale. |
double |
getTemperatureF()
Retrieve the temperature value using the Fahrenheit scale. |
java.util.Date |
getTimeOfReading()
Retrieve the date of when the temperature reading was made. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final double BOILING_C
public static final double BOILING_F
public static final double FREEZING_C
public static final double FREEZING_F
Constructor Detail |
public TemperatureReading4(char scale, double temperature, double latitude, double longitude)
scale
- specifies the scale for temperature, either 'F' or 'C'temperature
- the temperature in either Celsius or Fahrenheitlatitude
- the latitude of the readinglongitude
- the longitude of the readingMethod Detail |
public static double convertCtoF(double degreesC)
degreesC
- a number that is interpreted as a temperature in degrees Celsiuspublic static double convertFtoC(double degreesF)
degreesF
- a number that is interpreted as a temperature in degrees Fahrenheitpublic double getLatitude()
public double getLongitude()
public double getTemperatureC()
public double getTemperatureF()
public java.util.Date getTimeOfReading()
public java.lang.String toString()
toString
in class java.lang.Object