Define a new sumoftwo class that manages a simple addition


Problem

Define a new "SumOfTwo" class that manages a simple addition expression: operand-1 (integer) and operand-2 such as 10 + 5 or 20 + 2

The class must provide only the following public methods (no more and no less):

i. toString method must return all the SumOfTwo information as a string in the following format: SUM( operand1, operand2 ) = such as SUM(10, 5) = 15 Or SUM(20, 2) = 22 - 2 -

ii. isGreater method that compares with another SumOfTwo object and return true if the sum of the current SumOfTwo object is greater than the score of the other SumOfTwo object.

iii. hasOneOperandTheSame method that compares with another SumOfTwo object and returns true if they have at least one operand with the same value. For example, SUM(10, 5) and SUM(5, 2) will return true.

iv. isTheSame method that compares with another SumOfTwo object and returns true if they both have the same sum SUM(10, 5) and SUM(4, 11) will return true.

v. createDouble method that creates a brand-new SumOfTwo object with each operand having the double value of the current operands and return its pointer. SUM(10, 5) will create & return the object for SUM(20, 10)

Task

• Do not provide any other public method including get the sum of the two operands. Private methods are ok.

• The class must not provide the default constructor. It must require the two operand values to initialize the object.

• You must not declare the sum as one of the data members as it can be calculated when needed. Show how this SumOfTwo class being used to create objects and how these methods are being called and return proper values.

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Define a new sumoftwo class that manages a simple addition
Reference No:- TGS03311572

Expected delivery within 24 Hours