Class TemperatureReading4

java.lang.Object
   |
   +----TemperatureReading4

public class TemperatureReading4
extends 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.


Variable Index

 o BOILING_C
 o BOILING_F
 o CELCIUS
 o FAHRENHEIT
 o FREEZING_C
 o FREEZING_F

Constructor Index

 o TemperatureReading4()
The default constructor.
 o TemperatureReading4(double, char)
A constructor that specifies the scale for the temperature.

Method Index

 o convertCtoF(double)
A static method that converts numbers from a Celsius value to a Fahrenheit value.
 o convertFtoC(double)
A static method that converts numbers from a Fahrenheit value to a Celsius value.
 o getTemperatureC()
Retrieve the temperature value using the Celsius scale.
 o getTemperatureF()
Retrieve the temperature value using the Fahrenheit scale.
 o getTimeOfReading()
Retrieve a reference to the Date object that holds the time of the temperature reading.
 o setTemperatureC(double)
Set the temperature value using the Celsius scale.
 o setTemperatureF(double)
Set the temperature value using the Fahrenheit scale.
 o setTimeOfReading(Date)
Set the Date object that holds the time of the temperature reading.
 o toString()

Variables

 o BOILING_C
 public static final double BOILING_C
 o BOILING_F
 public static final double BOILING_F
 o FREEZING_C
 public static final double FREEZING_C
 o FREEZING_F
 public static final double FREEZING_F
 o CELCIUS
 public static final char CELCIUS
 o FAHRENHEIT
 public static final char FAHRENHEIT

Constructors

 o TemperatureReading4
 public TemperatureReading4()
The default constructor.

 o TemperatureReading4
 public TemperatureReading4(double temperature,
                            char scale)
A constructor that specifies the scale for the temperature. Throws an IllegalArgumentException if an improper temperature scale is specified.

Parameters:
temperature - the temperature in either Celsius or Fahrenheit
scale - specifies the scale for temperature, either FAHRENHEIT or CELCIUS

Methods

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

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

 o getTimeOfReading
 public Date getTimeOfReading()
Retrieve a reference to the Date object that holds the time of the temperature reading.

 o setTemperatureC
 public void setTemperatureC(double degreesC)
Set the temperature value using the Celsius scale. Throws IllegalArgumentException if the temperature value given is not realistic.

Parameters:
degreesC - new temperature value in degreees Celsius
 o setTemperatureF
 public void setTemperatureF(double degreesF)
Set the temperature value using the Fahrenheit scale. Throws IllegalArgumentException if the temperature value given is not realistic.

Parameters:
degreesF - new temperature value in degreees Fahrenheit
 o setTimeOfReading
 public void setTimeOfReading(Date newDate)
Set the Date object that holds the time of the temperature reading.

Parameters:
newDate - a reference to a Date object
 o toString
 public String toString()
Overrides:
toString in class Object
 o 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
 o 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