aspose file tools*
The moose likes Java in General and the fly likes US/Metric Conversion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "US/Metric Conversion" Watch "US/Metric Conversion" New topic
Author

US/Metric Conversion

C. Alan
Ranch Hand

Joined: Dec 17, 2004
Posts: 30
I'll admit right off that this is for an assignment, so please, no code samples. I just need a little help in understanding what my professor is trying to have us accomplish, because even though I know what we are going to do, the framework provided isn't making sense.

The package only consists of two classes, a unit class, and a conversion class. The unit class is really simple, and I understand what is happening with that.


The conversion code is where I get mystified, not the algortithms for the conversion, but accessing the correct data to do the conversion. In the constructor, we were given this:

The part I am having trouble understanding is how I access the correct instance of unit to retrieve the correct conversion values...

Thanks.

[ January 22, 2005: Message edited by: C. Alan ]
[ January 22, 2005: Message edited by: C. Alan ]

<a href="http://www.security-forums.com/forum/viewforum.php?f=48" target="_blank" rel="nofollow">Malware Removal</a> - Get your system running like new again.
C. Nimo
Ranch Hand

Joined: Mar 23, 2004
Posts: 82
yeah.. but what is it that you need to do?
basically, you probably need to access one or more instances of
Unit class in side Conversion.
You keep all those instances in an array called units[].
so - units[0] is the first Unit instance in the array, units[1] is
the second, and so on.
So, if you have a method named getWhatever() in your Unit class, and you
need to call it, you need to do something like this:



?
C. Alan
Ranch Hand

Joined: Dec 17, 2004
Posts: 30
Fair enough... let's try a more clear question.

For example, I want to convert 1 inch into centimeters. The first step is to convert it to meters (common unit). Then next conversion would be to convert to centimeters.

In our conversionTest, we will pass a string to Conversion as follows:

Conversion has a method:

I'm starting to get a glimmer of understanding here..Am I making a correct assumption that based on category and measure, the correct Unit will be returned, allowing me to get the necessary conversion??... what am I returning as a value though?

Sorry if my question is vague... I know what we are trying to do, but with the little bit of framework given, I am not understanding the implementation.
C. Alan
Ranch Hand

Joined: Dec 17, 2004
Posts: 30
Heh..I figured it out. I'm sure my instructor has a much more elegant solution, but as long as it works.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: US/Metric Conversion
 
Similar Threads
unable to recognize jndi name when using myeclipse3.8.3
key listeners for dynamically created buttons
Bad design to have JavaBeans with many attributes?
HELP ME PLEASE!!!
Serialization