I have been working on this program for quite a while, and can't figure out what's going on. In TestFraction, I use a while loop and Scanner to get two integers, a and b, from the user, and these values should be turned into the fraction a/b. This is done twice to create two fractions, fr1 and fr2. Then the class Fraction (which I created previously for another project) will perform operations on these two fractions. The issue I'm running into is that rather than getting the values of a and b from Scanner, as in my methods getFraction1 and getFraction2, the values of a and b seem to be set by their initial definition in Fraction, which is a=1, b=1. I know that these values are coming from Fraction because I've attempted to set a and b to other values when they are initialized in TestFraction. Can anyone give me some hints as to what's going on here? I'm quite new to
Java, and have a feeling that I'm not understanding something about inheritance.
Here is the output I get:
Input 1st fraction numerator and denominator
1
4
Input 2nd fraction numerator and denominator
3
4
1/1 + 1/1 = 2/1
1/1 - 1/1 = 0/1
1/1 * 1/1 = 1/1
1/1 / 1/1 = 1/1
1/1 1/1 1/1
Here is TestFraction:
And Fraction: