It's been driving me nuts! It works, when the object is passed, except for two cases (one where the minus sign shifts) and whenever there is a zero or a negative integer in the denominator. Any thoughts?
Also, I'm passing the function like validInput(c);
Does having zero in the denominator mean your trying to divide by zero? You also can't have a negative denominator since that "flips" the fraction:
1/-1 = -1/1
If you checking for valid input for a fraction the main things to bear in mind are you must have a non zero denominator and if the denominator is negative you need to flip the fraction.
But yeah setting the denominator to zero (especially when it could already be zero) should be changed.