my dog learned polymorphism
The moose likes Beginning Java and the fly likes Temperature Converter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Temperature Converter" Watch "Temperature Converter" New topic
Author

Temperature Converter

David Coello
Greenhorn

Joined: Jun 05, 2012
Posts: 22
Hello forum members,

I am a new java developer. I have been working on a Converter from Farenheit to Celsius with the push of a button. I programmed it under those specs, but I would like to program that same button to convert back to celsius. I appreciate your comments, basically if a button can perform 2 actions, convert from Fahrenheit to Celsius and Celsius to Farenheit.


Thank you.

David

Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 32508
    
214

Yes, the same button can do two things. You'd need an instance variable to remember which state the button is in so you know which label to display and which action to perform.


[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
check which textfield is empty, via .equals(""), ensuring both are not empty,
then convert the non-empty for display in the empty
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Temperature Converter
 
It's not a secret anymore!