Class TemperatureReading4

java.lang.Object
  |
  +--TemperatureReading4

public class TemperatureReading4
extends java.lang.Object

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()
          The default constructor.
TemperatureReading4(double temperature, char scale, double newLat, double newLong)
          A constructor that specifies the 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()
           
 double getLongitude()
           
 double getTemperatureC()
          Retrieve the temperature value using the Celsius scale.
 double getTemperatureF()
          Retrieve the temperature value using the Fahrenheit scale.
 java.util.Date getTimeOfReading()
           
 void setLatitude(double newLat)
           
 void setLongitude(double newLong)
           
 void setTemperatureC(double degreesC)
          Set the temperature value using the Celsius scale.
 void setTemperatureF(double degreesF)
          Set the temperature value using the Fahrenheit scale.
 void setTimeOfReading(java.util.Date newDate)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BOILING_C

public static final double BOILING_C

BOILING_F

public static final double BOILING_F

FREEZING_C

public static final double FREEZING_C

FREEZING_F

public static final double FREEZING_F
Constructor Detail

TemperatureReading4

public TemperatureReading4()
The default constructor.

TemperatureReading4

public TemperatureReading4(double temperature,
                           char scale,
                           double newLat,
                           double newLong)
A constructor that specifies the scale for the temperature.
Parameters:
temperature - the temperature in either Celsius or Fahrenheit
scale - specifies the scale for temperature, either 'F' or 'C'
newLat - the latitude of the reading
newLong - the longitude of the reading
Method Detail

getTemperatureC

public double getTemperatureC()
Retrieve the temperature value using the Celsius scale.

getTemperatureF

public double getTemperatureF()
Retrieve the temperature value using the Fahrenheit scale.

getLatitude

public double getLatitude()

getLongitude

public double getLongitude()

getTimeOfReading

public java.util.Date getTimeOfReading()

setTemperatureC

public void setTemperatureC(double degreesC)
Set the temperature value using the Celsius scale. (If the temperature value given is not realistic, the temperature will be set to the default temperature.)
Parameters:
degreesC - new temperature value in degreees Celsius

setTemperatureF

public void setTemperatureF(double degreesF)
Set the temperature value using the Fahrenheit scale. (If the temperature value given is not realistic, the temperature will be set to the default temperature.)
Parameters:
degreesF - new temperature value in degreees Fahrenheit

setLatitude

public void setLatitude(double newLat)

setLongitude

public void setLongitude(double newLong)

setTimeOfReading

public void setTimeOfReading(java.util.Date newDate)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

convertCtoF

public static double convertCtoF(double degreesC)
A static method that converts numbers from a Celsius value to a Fahrenheit value.
Parameters:
degreesC - a number that is interpreted as a temperature in degrees Celsius

convertFtoC

public static double convertFtoC(double degreesF)
A static method that converts numbers from a Fahrenheit value to a Celsius value.
Parameters:
degreesF - a number that is interpreted as a temperature in degrees Fahrenheit