CSC1020 Homework 4
Overview
We are going to take our calculator that we created in Homework 3 and reimplement it using FXML, adding a few features to it in the process.
Details
- Create a new Java project in IntelliJ.
- Use the following filenames in IntelliJ:
- Calculator.java -> the Main class
- CalculatorController.java
- Calculator.fxml
- Rename the package to your username.
- Using SceneBuilder, recreate your interface. Make sure to:
- Associate the scene with your
.CalculatorController - Bind the operand TextFields and equals button to the same handler
- Assign fx:id to all of the controls you will be interacting with
- Associate the scene with your
- Code must be in its appropriate file
- All view information should be defined in the FXML file (View)
- All interaction between the user and the view should be defined in the Controller class (Controller)
- All computation and non-GUI related code should be in the Calculator class (Model)
Additional Functionality
In addition to adding the two operands and changing the TextField background to red if the result is negative, we will add the following functionality:
- Clicking on the operator button will change the button text to a new operator. You should be able to perform addition, subtraction, multiplication, division, and modulus operations.
- The handler bound to the equals button and TextFields will perform the operation displayed in the operator button.
- If an illegal operation were to occur, the program will display the following: