Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

comparison methods

 
eric elysia
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having some problems with this comparison method.

Thank you,
Eric

 
Jimmy Die
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


Could you be more specific as to what your problem is.

Thanks
 
eric elysia
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am having a hard time testing the comparison methods of my program. Everything else tests ok. I am not sure if I need to keep the comparison methods that I have and rewrite the testing code, or rewrite the comparison methods and keep the testing code.

Thank you,
Eric

 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm afraid that you will have to be more specific as to what your problem is. I took the code that you posted and ran it, and it ran fine (after I substituted my own functions for the SavitchIn class, of course...)

I double checked all of the statements printed, and they all printed correctly. What problem are you receiving? An error, or is one of your calculations wrong?
 
eric elysia
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My problem was this: My comparison methods are boolean. I wasn't sure what to do if both of the temperature scales were the same, but I think I'm on to something now.

Let me know if you need any more info, if I am doing the right thing, or if I am off in left field somewhere. Sorry about the Savitch code. That is the author of my textbook. It is a file that was created to run these methods.

Thanks,
Eric

 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not a problem about the Savitch code...enough people here use it, I really should find a copy of it so that I can help without substituting my own code.

Why should it matter if both scales are the same or not? The greaterThan method handles that by calling getC or getF appropriately. It just concerns itself with the scale of the current object and makes sure it reads the value of the other object in that scale, so the other object's actual scale doesn't matter.

In other words, I don't see any problems.
 
eric elysia
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
eric elysia
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why should it matter if both scales are the same or not? The greaterThan method handles that by calling getC or getF appropriately. It just concerns itself with the scale of the current object and makes sure it reads the value of the other object in that scale, so the other object's actual scale doesn't matter.


Do you mean that you don't see any problems since I rewrote it? The main problem I had was this: I was using a boolean as a comparison method. The boolean can only return two values. I know you already know this.



This is what I was having problems with. I hope I am on the right track with the new code I just wrote (and posted).

Thanks,
Eric
 
eric elysia
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure you scroll up and get the Savitch class. It is very handy.

Eric
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please see the original thread for my explaination of the problem with this latest rewriting of the comparison method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic