Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Add method
- public Rational add(Rational passedIn)
- {
- int addedNum, newDen, multiplier;
- Rational addedRat = null;
- if(this.den == passedIn.den)
- {
- addedNum = this.num + passedIn.num;
- newDen = this.den;
- }//end for
- else
- {
- newDen = this.den * passedIn.den;
- addedNum = (this.num * passedIn.den) + (this.den * passedIn.num);
- }//end else
- addedRat = new Rational(addedNum, newDen);
- reduce();
- return addedRat;
- }//end add
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement