Design and implement an abstract base class arithmetic


1. Design and implement an abstract base class ArithmeticExpression that represent any binary (having two arguments) arithmetic expression. In this coursework you will be implementing various subclasses of this class. The abstract class should include at least
two methods called evaluate and display which are described below. 
2. Design and implement concrete (non-abstract) classes which are subclasses of the class ArithmeticExpression and represent some simple arithmetic expression. The operations that you should implement for each subclass should include the binary (i.e. accepting exactly two arguments) operations of addition, subtraction, multiplication and division (all of them accepting double type arguments). Using the classes you should be able to represent for example an expression like "(5.0+8.1)*(2.0)" (not in this format but represent the overall expression in an equivalent way). To design your classes you should think what common functionality and di erences ( elds and methods) these classes share and place such functionality at the appropriate place of the class hierarchy. Implement methods evaluate and display. Method evaluate evaluates the arithmetic expression that the object represents and returns the result as a double. For exam- ple, calling it in an object representing expression "(5.0+8.1)*(2.0)" should return 26.2. Method display prints the raw (unevaluated) expression on the screen. For example, calling it in an object representing expression "(5.0+8.1)*(2.0)" should display the string "(5.0+8.1)*(2.0)" (without the quotes). You shoud NOT use static methods!

3. Implement a test class CalculatorTest which tests the functionality of your classes (the methods of your classes should be called and make sure that they do what they are supposed to do).
1
4. Implement a class RandomCalculations which creates a random number of random ex-pressions and uses your classes above to evaluate and display them. Test its functionality by calling its methods in the CalculatorTest class above 

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: Design and implement an abstract base class arithmetic
Reference No:- TGS0143947

Expected delivery within 24 Hours