Hey.
This problem might be simple but i seem to mess it up anyways.
I have two classes, one main and one fraction class.
They are ment to do different things to fraction.
Main:
public class ourM { public static void main(String[] args) { fraction f1 = new fraction(3, 4); f1.toString(); fraction f2 = new fraction(4, 6); } }
Fraction:
public class fraction { private int t; private int n; public fraction(int t, int n) { this.t = t; this.n = n; System.out.println("The fraction is : " + this); } public String toString() { return new String(t + "/" + n); } public int getNumertor(int n) { this.n = n; return n; } public int getDenominator(int t) { this.t = t; return t; } boolean isNegative() { if ((getDenominator(t) / getNumertor(n)) < 0) { return true; } return false; } }
But when i do something such (toString) i get it twice when i really only want it once because
i only called it once... so i am guessing that there is something that i am missing.