class Fraction { int top; int bottom; public Fraction(int top, int bottom) { this.top = top; this.bottom = bottom; } public Fraction Add(int newTop, int newBottom) { if (newBottom == this.bottom) { return Fraction((this.top + newTop), this.bottom); } Fraction tempFractionA = new Fraction((this.top * newBottom), (this.bottom * newBottom)); Fraction tempFractionB = new Fraction((newTop * this.bottom), (newBottom * this.bottom)); return tempFractionA.Add(tempFractionB); } public Fraction Add(Fraction newFraction) { if (this.bottom == newFraction.bottom) { return Fraction((this.top + newFraction.top), newFraction.bottom); } Fraction tempFractionA = new Fraction((this.top * newFraction.bottom), (this.bottom * newFraction.bottom)); Fraction tempFractionB = new Fraction((newFraction.top * this.bottom), (newFraction.bottom * this.bottom)); return tempFractionA.Add(tempFractionB); } public Fraction Add(int newTop) { int newBottom = 1; if (newBottom == this.bottom) { return Fraction((this.top + newTop), this.bottom); } Fraction tempFractionA = new Fraction((this.top * newBottom), (this.bottom * newBottom)); Fraction tempFractionB = new Fraction((newTop * this.bottom), (newBottom * this.bottom)); return tempFractionA.Add(tempFractionB); } public Fraction Subtract(int newTop, int newBottom) { if (newBottom == this.bottom) { return Fraction((this.top - newTop), this.bottom); } Fraction tempFractionA = new Fraction((this.top * newBottom), (this.bottom * newBottom)); Fraction tempFractionB = new Fraction((newTop * this.bottom), (newBottom * this.bottom)); return tempFractionA.Add(tempFractionB); } public Fraction Subtract(Fraction newFraction) { if (this.bottom == newFraction.bottom) { return Fraction((this.top - newFraction.top), newFraction.bottom); } Fraction tempFractionA = new Fraction((this.top * newFraction.bottom), (this.bottom * newFraction.bottom)); Fraction tempFractionB = new Fraction((newFraction.top * this.bottom), (newFraction.bottom * this.bottom)); return tempFractionA.Add(tempFractionB); } public Fraction Subtract(int newTop) { int newBottom = 1; if (newBottom == this.bottom) { return Fraction((this.top - newTop), this.bottom); } Fraction tempFractionA = new Fraction((this.top * newBottom), (this.bottom * newBottom)); Fraction tempFractionB = new Fraction((newTop * this.bottom), (newBottom * this.bottom)); return tempFractionA.Add(tempFractionB); } public Fraction Multiply(int newTop, int newBottom) { return Fraction((this.top * newTop), (this.bottom * newBottom)); } public Fraction Multiply(Fraction newFrac) { return Fraction((this.top * newFrac.top), (this.bottom * newFrac.bottom)); } public Fraction Multiply(int newTop) { return Fraction((this.top * newTop), this.bottom); } public Fraction Divide(int newTop, int newBottom) { return Fraction((this.top * newBottom), (this.bottom * newTop)); } public Fraction Divide(Fraction newFrac) { return Fraction((this.top * newFrac.bottom), (this.bottom * newFrac.top)); } public Fraction Divide(int newTop) { return Fraction((this.top), (this.bottom * newTop)); } }