Question 3 In this exercise, you will design a simple calculator with four basic operations, namely addition, subtractio
Posted: Tue Jul 12, 2022 8:05 am
Question 3 In this exercise, you will design a simple calculator with four basic operations, namely addition, subtraction, multiplication, and division. Implementation of this simple calculator should separate the code for user interface and mathematical operations. The code for performing mathematical operations should be designed using the following class hierarchy: Addon computex double, y: deuble): double Operation computer double y double): double Multiplication computer double, y: double): double Subtraction . computex: double, y: double): double computex: double, y: double): double The Operation class hierarchy contains the logic for performing various mathematical operations. A concrete class in this hierarchy represents one mathematical operation, which is performed in its compute() function that returns the result of an operation. Implement the Factory method design pattern using one factory class named OperationFactory so that an instance of a class in the Operation class hierarchy can be created based on the requested operation (+,-, +, /). Additionally, OperationFactory should also be an implementation of Singleton. The user interface for the calculator should make use of five QPushbuttons, two QDoubleSpinBoxes and one QLCDNumber as shown below: Division 8 0 D X COS3711/Assignment 2/2022 QDoubleSpinBoxes allow user to enter numbers and QLCDNumber is for displaying the result of the calculation. To use the calculator, the user should first enter two numbers and then select one of the four (+,-, +, /) buttons. The result of the operation is displayed in QLCDNumber. The button clear is used to clear QDoubleSpinBoxes and QLCDNumber. Note the following: The signals emitted by the four buttons (+,-. +. /) should be handled in a single slot. The user interface code should make use of the Operation class hierarchy to get the result of the requested operation. Handle overflow in QLCDNumber display appropriately. Handle division by 0 appropriately.