public static Fraction operator +(Fraction frac1, Fraction frac2) { Fraction frac5 = new Fraction(); frac5.setB((frac1.den * frac2.den)); frac5.setA(((frac1.num * frac2.den) + (frac2.num * frac1.den))); return frac5; }
public static Fraction operator *(Fraction frac1, Fraction frac2) { Fraction frac3 = new Fraction(); frac3.setA((frac1.num * frac2.num)); frac3.setB((frac1.den * frac2.den)); return frac3; }
public static Fraction operator -(Fraction frac1, Fraction frac2) { Fraction frac6 = new Fraction(); frac6.setB((frac1.den * frac2.den)); frac6.setA(((frac1.num * frac2.den) - (frac2.num * frac1.den))); return frac6; }
public static Fraction operator ++(Fraction a) { Fraction frac6 = new Fraction(); frac6.setB(a.den); frac6.setA(a.num + a.den); return frac6; }
public static Fraction operator +(Fraction frac2, int n) { Fraction frac6 = new Fraction(); frac6.setB(frac2.den); frac6.setA(frac2.num + frac2.den); return frac6; }
// obj - int public static Fraction operator -(Fraction frac2, int n) { Fraction frac6 = new Fraction(); frac6.setB((frac2.den * n)); frac6.setA(((frac2.num * n) - (frac2.num * n))); return frac6; }
// int - obj public static Fraction operator -(int n, Fraction frac2) { Fraction frac6 = new Fraction(); frac6.setB(frac2.den); frac6.setA((frac2.den * n) - frac2.num); return frac6; }