/*** Temperature.doc *************************************************** The operations on Temperature objects are:

advertisement
/*** Temperature.doc ***************************************************
The operations on Temperature objects are:
Constructors:
Default
Explicit value
Access methods:
Degrees() : returns the value of the myDegrees data member
Scale() : returns the value of the myDegrees data member
Conversions:
Fahrenheit() : converts a Temperature to Fahrenheit
Celsius() : converts a Temperature to Celsius
Kelvin() : converts a Temperature to Kelvin
Arithmetic operators:
Temperature addition (+) and subtraction (-)
Relational operators:
== and <
I/O
Read() and Print()
-------------------- Function Specifications --------------------Constructors:
Default:
Temperature()
Initializes myDegrees to 0.0 and myScale to 'C'
Postcondition: (myDegrees == 0.0) && (myScale == 'C')
Explicit-Value:
Temperature(double initialDegrees, char initialScale)
Receive: initialDegrees, a double
initialScale, a char
Precondition: initialScale is one of
{'f', 'c', 'k', 'F', 'C', 'K'}
Postcondition: myDegrees == initialDegrees &&
myScale == initialScale in uppercase
Accessor Functions:
double Degrees() const;
Returns:
value stored in myDegrees data member
char Scale() const;
Returns:
value stored in myScale data member
Input/Output Functions
void Read(istream & in);
Receive: in, an istream containing a double and a char
Input: inDegrees, the double value, and inScale, the char value
Precondition: inScale is one of {'f', 'c','k', 'F', 'C', 'K'}
Pass back: in, with inDegrees and inScale extracted from it
Postcondition: myDegrees == inDegrees && myScale == inScale
void Print(ostream & out) const;
Receive: out, an ostream
Output: inDegrees, the double value, and inScale, the char value
Pass back: out, with inDegrees and inScale inserted into it
Conversion Functions
Temperature Fahrenheit() const;
Return:
The Fahrenheit temperature equivalent to the Temperature
represented by the object containing this function
Temperature Celsius() const;
Return:
The Celsius temperature equivalent to the Temperature
represented by the object containing this function
Temperature Kelvin() const;
Return:
The Kelvin temperature equivalent to the Temperature
represented by the objet containing this function
Arithmetic Operators
Temperature operator+(double rightOperand) const;
Receive: rightOperand, a double value.
Return: resultTemp, a Temperature such that
resultTemp.myScale == myScale, and
resultTemp.myDegrees == myDegrees + rightOperand.
Temperature operator-(double rightOperand) const;
Receive: rightOperand, a double value.
Return: resultTemp, a Temperature such that
resultTemp.myScale == myScale, and
resultTemp.myDegrees == myDegrees - rightOperand.
Relational Operators
int Compare(const Temperature & rightOperand) const;
Receive: rightOperand, a Temperature value.
Return: -1, 0, 1 according to whether the Temperature represented by
the object containing this function is less than, equal to,
or greater than rightOperand
bool operator<(const Temperature & rightOperand) const;
Receive: rightOperand, a Temperature value.
Return: true if and only if the Temperature represented by
the object containing this function is less than
rightOperand
bool operator==(const Temperature & rightOperand) const;
Receive: rightOperand, a Temperature value.
Return: true if and only if the Temperature represented by
the object containing this function is equal to rightOperand
... Documentation for other relational operators is omitted . . .
***********************************************************************/
Download