public class ProperRational : Rational { private int whole; public ProperRational() : base() // Constructor if no input values are used. { whole = 0; } // Normal constructor. public ProperRational(int whl, int num, int denom) : base(num, denom) { whole = whl; } public void SetProperRational(int whl, int num, int denom) { whole = whl; numerator = num; denominator = denom; Reduce(this); } protected void Reduce(ProperRational myRational) { base.Reduce(this); int sign; sign = this.RemoveSign(); this.whole = this.whole + (this.numerator / this.denominator); // Integer math this.numerator = this.numerator % this.denominator; this.AddSign(sign); } // end Reduce public static ProperRational operator + (ProperRational One, ProperRational Two) { ProperRational Pr = new ProperRational(); Pr.AddProperRational(One, Two); return Pr; } public void AddProperRational(ProperRational One, ProperRational Two) { int sign; // First rational. Remove the sign, convert to an improper rational, // then put the sign back. sign = One.RemoveSign(); One.numerator = One.numerator + One.whole * One.denominator; One.whole = 0; One.AddSign(sign); // Second rational. Remove the sign, convert to an improper rational, // then put the sign back. sign = Two.RemoveSign(); Two.numerator = Two.numerator + Two.whole * Two.denominator; Two.whole = 0; Two.AddSign(sign); // Add the improper rationals. base.AddRational(One, Two); // Convert back to a proper rational. Reduce(One); Reduce(Two); Reduce(this); } public static ProperRational operator - (ProperRational One, ProperRational Two) { //Insert your code here. } public void SubProperRational(ProperRational One, ProperRational Two) { //Insert your code here. } public static ProperRational operator * (ProperRational One, ProperRational Two) { //Insert your code here. } public void MulProperRational(ProperRational One, ProperRational Two) { //Insert your code here. } public static ProperRational operator / (ProperRational One, ProperRational Two) { //Insert your code here. } public void DivProperRational(ProperRational One, ProperRational Two) { //Insert your code here. } public string StringProperRational() { //Insert your code here. } public double DoubleProperRational() { //Insert your code here. } public int Whole { get { return whole; } } private int RemoveSign() { // Temporarily take the sign out of the rational. int sign = 1; //1 = positive, -1 = negative if ((this.whole != 0) && (this.numerator != 0) && (Math.Abs(this.whole * this.numerator) != (this.whole * this.numerator))) sign = -1; if ((this.whole == 0) && (Math.Abs(this.numerator) != this.numerator)) sign = -1; if ((this.numerator == 0) && (Math.Abs(this.whole) != this.whole)) sign = -1; this.whole = Math.Abs(this.whole); this.numerator = Math.Abs(this.numerator); return sign; } private void AddSign(int sign) { // Put the sign back onto the rational. if (this.whole !=0) this.whole *= sign; else this.numerator *= sign; } }