Hi, although by now I know enough about making methods and constructors, they're definition...I don't know why I have problem with this exercise of my teacher...now I don't want anyone to write the code, I'm just asking for some advice to find out what I'm doing wrong
here's the problem:
Make a class Rational to provide at least following methods and constructors:
Rational b1= new Rational (2,7);
Rational b2= new Rational (3,6);
Rational b3=b1.add(b2);
now, so far I made a class named Rational, with a constructor that takes two arguments, for numerator and denominator...but a constructor can't return anything, while in the example above(provided by the teacher), by calling the constructor, we made a Rational object with value 2/7!
how is that possible? cuz when I printout b1 or b2, it doesn't give me the value 2/7 or 3/6, rather something like Rational@5c09036e
I know I can make a method that makes rational number, but according to this example, we have to make that object by calling the constructor!
I hope someone figures out where I'm making mistake lol, I'm not sure if the things I'm saying even make sense! or maybe I have not understood the problem correctly, in any ways, any help would be appreciated....