One last change
The calculator works as it is. Still, as a design consideration, consider that at some time in the future you might want to change the numeric display on the calculator. You might want to either change the STCalculator class or subclass it to use something different than a CwText as the display.
To make this possibility easier, let's change the name of the instance variable textWidget to display. The name textWidget reveals too much of the current implementation of the display, which might change in the future.
How should you do this? You cannot just go and change the name of the variable. Some methods refer to this variable, and when you save the definition of a class, all of its methods get recompiled. Those methods which reference textWidget do not compile. Do the following to change the variable:
1. In the Applications Browser, select the STCalculatorApp application; then select the STCalculator class.
2. Add display as an instance variable. Do not remove textWidget yet. Save the text.
3. After the class has recompiled, from the Classes menu, select Browse References > To An Instance Variable.
4. Select textWidget, then OK. A References browser opens. The top pane contains the methods that refer to textWidget.
5. Select STCalculator>>addButtonsTo:. The source code for the method is displayed in the lower pane, with the first reference to textWidget highlighted.
6. Replace the highlighted textWidget with display. Save the method from this pane.
7. Select the next method, addDisplayTo:. Note that the title of the window now reads (1 of 2). This indicates that addDisplayTo: refers to textWidget two times.
8. Replace the first occurrence of textWidget with display.
9. From the Methods menu, select Next Range. The browser moves to the second reference.
10. Change the remaining references to display, making sure to save each method as you go.
11. Close the References browser.
12. In the Applications Browser, remove textWidget from the definition of STCalculator. Save the class definition.
You have now changed the name of the instance variable.
Since this is the last thing, now good time to save your image. From the Transcript, Choose Save Image... from the File pull down menu.
 
Last modified date: 06/27/2019