}//End RomanClass operator + //Subtraction override //RomanClass operator - ------------------------------------------------ //Pre:Object has been instantiated //Post: overrides the subtraction letting the two string subtract from one another //Purpose: returns the class initiated in the method set to the subtraction of the two strings public static RomanClass operator -(RomanClass leftOp, RomanClass rtOp) { RomanClass rtn = new RomanClass(); //set an instance of the Roman Class for the return value int intNumR = rtOp.ConvertToDecimal(); //Converts first number to decimal int intNumL = leftOp.ConvertToDecimal(); //Converts the second button to decimal int intTotal = 0; if (leftOp > rtOp) { intTotal = intNumL - intNumR; //subtracts the left from the right } else if (leftOp < rtOp) { intTotal = intNumR - intNumL; //subtracts the right from the left } rtn.SetString(intTotal); //Sets the PDM of the return value. return(rtn); //Returns the value }//End RomanClass operator -
//Addition Override //RomanClass operator + ------------------------------------------------------ //Pre:Object has been instantiated //Post: overrides the addition letting the two string add together //Purpose: returns the class initiated in the method set to the sum of the two strings public static RomanClass operator +(RomanClass leftOP, RomanClass rtOP) { RomanClass rtn = new RomanClass(); //set an instance of the Roman Class for the return value int intNum1 = leftOP.ConvertToDecimal(); //Converts the second button to decimal int intNum2 = rtOP.ConvertToDecimal(); //Converts first number to decimal int intTotal = intNum1 + intNum2; //Adds the two numbers together //Checks to make sure the number is not over 3999 if (intTotal > 3999) { intTotal = 0; } rtn.SetString(intTotal); //Sets the PDM of the return value. return(rtn); //Returns the value }//End RomanClass operator +