Package calculator
Class CalculatorController
java.lang.Object
calculator.CalculatorController
- All Implemented Interfaces:
ActionListener
,TextListener
,EventListener
This class represents the controller in the MVC architecture for a calculator application.
It handles all the listener event from view and perform operation using model.
- Since:
- 24 Aug 2023
- Version:
- 1.0.0
- Author:
- Shamith Nakka
-
Field Summary
Modifier and TypeFieldDescriptionprivate final CalculatorModel
private StringBuilder
private final CalculatorView
-
Constructor Summary
ConstructorDescriptionConstructs a new CalculatorModel instance.CalculatorController
(CalculatorView view, CalculatorModel model) Constructs a new CalculatorModel instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
actionPerformed
(ActionEvent event) This is an event-handler will handle all the button events.void
textValueChanged
(TextEvent event) This is an event-handler that make sure only numeric character are present within the text field.
-
Field Details
-
model
-
textFieldCurrentText
-
view
-
-
Constructor Details
-
CalculatorController
public CalculatorController()Constructs a new CalculatorModel instance. This constructor initializes any required data or resources. -
CalculatorController
Constructs a new CalculatorModel instance. This constructor initializes with provided data or resources.- Parameters:
view
- : a CalculatorView instance.model
- : a CalculatorModel instance.
-
-
Method Details
-
actionPerformed
This is an event-handler will handle all the button events.- Specified by:
actionPerformed
in interfaceActionListener
-
textValueChanged
This is an event-handler that make sure only numeric character are present within the text field.- Specified by:
textValueChanged
in interfaceTextListener
-