Answered You can hire a professional tutor to get the answer.

QUESTION

Design and implement an abstract base class ArithmeticExpression that represent any binary (having two arguments) arithmetic expression.

1. Design and implement an abstract base class ArithmeticExpression that represent anybinary (having two arguments) arithmetic expression. In this coursework you will beimplementing various subclasses of this class. The abstract class should include at leasttwo methods called evaluate and display which are described below. (15 marks).2. Design and implement concrete (non-abstract) classes which are subclasses of the classArithmeticExpression and represent some simple arithmetic expression. The operationsthat you should implement for each subclass should include the binary (i.e. acceptingexactly two arguments) operations of addition, subtraction, multiplication and division(all of them accepting double type arguments). Using the classes you should be able torepresent for example an expression like "(5.0+8.1)*(2.0)" (not in this format but representthe overall expression in an equivalent way).To design your classes you should think what common functionality and dierences (eldsand methods) these classes share and place such functionality at the appropriate place ofthe class hierarchy.Implement methods evaluate and display. Method evaluate evaluates the arithmeticexpression 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!(45 marks)3. Implement a test class CalculatorTest which tests the functionality of your classes (themethods of your classes should be called and make sure that they do what they aresupposed to do). (10 marks).14. 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 functionalityby calling its methods in the CalculatorTest class above (20 marks).

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question