Class Temperature

java.lang.Object
  extended by Temperature

public class Temperature
extends java.lang.Object

Temperature.java Class for temperature objects Ref: #7,413,4th AHD, Thurs 18th October 2007, 11:10 PT Please report any errors or omissions in this file. This is a class designed primarily to represent temperature records. It allows default initialisations of variables, get and set methods for variables, temperature comparison and conversion methods. To help with the understanding of the class, this java code has been commented for javadoc.exe, p1034-1035,4th Ed following the style in SavitchIn.java javadoc.exe has been run on this file (see instructions below) to create a web page documenting the Temperature.java class. You can inspect this webpage at: http://www.annedawson.com/Temperature.html To run javadoc, assuming the Java SDK is located here: C:\j2sdk1.4.2_01 and assuming the Temperature.java file is in C:\temp Click on the Start button on the desktop Select Run Browse for this file: C:\j2sdk1.4.2_01\bin\javadoc.exe and in the Run textbox add the text exactly as here: C:\j2sdk1.4.2_01\bin\javadoc.exe -d c:\temp C:\temp\Temperature.java and click on OK to run IMPORTANT NOTE: if you installed java to the Program Files folder, for "Program Files" substitute "Progra~1" in the path, e.g.: C:\Progra~1\Java\jdk1.6.0_02\bin\javadoc.exe -d c:\temp C:\temp\Temperature.java the "-d c:\temp" is a javadoc flag specifying that the destination folder to write the html documentation files to is C:\temp when you supply a .java file name to javadoc, you must give the full path, e.g. C:\temp\Temperature.java Reference: www.annedawson.com/javadoc.htm


Constructor Summary
Temperature()
          Default Constructor: sets temperature to O and scale to 'C'
Temperature(char s)
          Constructor: initialises scale to parameter s
Temperature(double t)
          Constructor: initialises temperature to parameter t
Temperature(double t, char s)
          Constructor: initialises scale to parameter s and temperature to t
 
Method Summary
 boolean equals(Temperature otherObject)
          General method: checks if objects have equal temperatures
 double getCelsiusTemperature()
          Accessor method: gets the C temperature value
 double getFahrenheitTemperature()
          Accessor method: gets the F temperature value
 boolean greaterThan(Temperature otherObject)
          General method: checks if temperature of current object is greater than that of other object
 boolean lessThan(Temperature otherObject)
          General method: checks if temperature of current object is less than that of other object
 void set(char newScale)
          Mutator method: sets the object's scale value with param
 void set(double newTemp)
          Mutator method: sets the object's temperature value with param
 void set(double newTemp, char newScale)
          Mutator method: sets the object's scale and temperature values with params
 void writeOutput()
          General method: writes the object's values to screen
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Temperature

public Temperature()
Default Constructor: sets temperature to O and scale to 'C'


Temperature

public Temperature(double t)
Constructor: initialises temperature to parameter t

Parameters:
t - This is a number representing the temperature

Temperature

public Temperature(char s)
Constructor: initialises scale to parameter s

Parameters:
s - This is a character representing the scale

Temperature

public Temperature(double t,
                   char s)
Constructor: initialises scale to parameter s and temperature to t

Parameters:
s - This is a character representing the scale
t - This is a number representing the temperature
Method Detail

getCelsiusTemperature

public double getCelsiusTemperature()
Accessor method: gets the C temperature value

Returns:
The temperature in Celcius

getFahrenheitTemperature

public double getFahrenheitTemperature()
Accessor method: gets the F temperature value

Returns:
The temperature in Fahrenheit

writeOutput

public void writeOutput()
General method: writes the object's values to screen


set

public void set(double newTemp)
Mutator method: sets the object's temperature value with param

Parameters:
newTemp - This is the new temperature.

set

public void set(char newScale)
Mutator method: sets the object's scale value with param

Parameters:
newScale - This is the new scale.

set

public void set(double newTemp,
                char newScale)
Mutator method: sets the object's scale and temperature values with params

Parameters:
newTemp - This is the new temperature.
newScale - This is the new scale.

equals

public boolean equals(Temperature otherObject)
General method: checks if objects have equal temperatures

Parameters:
otherObject - This is the object to compare to the current object

greaterThan

public boolean greaterThan(Temperature otherObject)
General method: checks if temperature of current object is greater than that of other object

Parameters:
otherObject - This is the object to compare to the current object

lessThan

public boolean lessThan(Temperature otherObject)
General method: checks if temperature of current object is less than that of other object

Parameters:
otherObject - This is the object to compare to the current object