|
Hello,
I am working on a temperature program. I am almost finished. My last methods are comparison methods. I cannot figure out how to test (or rewrite) my comparison methods.
Here's part of my code:
//comparison method to test whether one temperature is less than another.
public boolean lessThan(Temperature t)
{
if(this.tempScale == (t.tempScale))
{
return(this.tempScale == t.tempScale);
}
else if(this.tempScale == 'C')//this is C
{
return(this.tempValue < (t.getC()));
}
else //this is F
{
//return(this.tempValue < (t.getF()));
}
Here is the code I am trying to test:
//t28 and t29 test the greaterThan method to show that both scales are the same (not greater)
Temperature t28 = new Temperature(100.0, 'f');
Temperature t29 = new Temperature(102.0, 'f');
if(t28.greaterThan(t29))
{
System.out.println("100.0 degrees F is greater than 102.0 degrees F.");
}
else
{
System.out.println("100.0 degrees F is not greater than 102.0 degrees F.");
}
I am not sure what I should do if both temperatures have the same scaleValue.
Any help is appreciated.
Thanks,
Eric
|
|
|
|
|
|
|
|