I'm trying to create a clone method that will take an already created Rational and make a copy so that in my main I can do something like this:
Rational r3 = new Rational(r1);
So far I created a method in my Rational class that will take in a rational as a parameter; however I am not sure how to make the new instance look just like the parameter.
public Rational copy(Rational aRational) {
int newNum = aRational.n;
int newDenom = aRational.d;
return (new Rational(newNum, newDenom));
}
Any help or insight is greatly appreciated!!