User Profile

Collapse

Profile Sidebar

Collapse
zlwilly
zlwilly
Last Activity: Oct 29 '08, 08:58 PM
Joined: Oct 29 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • zlwilly
    replied to Writing a .equals method to compare fractions
    in Java
    I figured it out! Needed to do this instead. Don't know what I was thinking. Thanks!

    Code:
     
    public boolean equals(Fraction otherFraction)    
    {
          return ((n == otherFraction.n) && (d == otherFraction.d));    
    }
    See more | Go to post

    Leave a comment:


  • zlwilly
    replied to Writing a .equals method to compare fractions
    in Java
    Right, I used Euclid's algorithm to bring them down (by finding the greatest common denominator.) I understand the concept, but it was the code that was giving me trouble. The examples I had been looking at were comparing dates consisting of month, day, and year, which meant the boolean was checking that all were the same using &&. Is this the way I should check both denominator and numerator? It's the syntax. That's what always gets me....
    See more | Go to post

    Leave a comment:


  • zlwilly
    started a topic Writing a .equals method to compare fractions
    in Java

    Writing a .equals method to compare fractions

    Hi everyone!

    I have written two classes, Fraction and useFraction. Fraction holds all of the methods required to process the data from useFraction, which consists of private ints that are turned into separate fractions. The source for the classes looks like this:

    useFraction looks like this:
    Code:
     
    public class useFraction 
    {
         public static void main(String[] args)  
        {
    ...
    See more | Go to post
No activity results to display
Show More
Working...