codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Help with comparison method  ericelysia at 12:09 on Monday, March 07, 2005
 

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








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: C# and EXCEL question saving a file saving the the first column as read only
•  Iexplore -
•  Iframe and Div Layer Scrollbar Problem
•  Left margin increases as page fills.....
•  Re: Parse error that is slowly driving me insane
•  simple javascript/dhtml drop-down menu
•  notify an object that the user interface has changed one of its properties
•  Re: Print and print preview file on the website without using the File - Print on the IE
•  how we convert image into byte array in rmi


Recent Articles
Communicating with the Database (Using ADO)
MagicGrid
Simple Thumbnail Browsing Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2005