Java Reference
In-Depth Information
Testing the Calculator Application
Testing the Calculator application will involve performing operations and
displaying results. The following steps test the calculations performed by the
Calculator application.
To Test the Application
1. With the Calculator Application window still open, click the 2 button
and then click the 7 button on the keypad.
The digits display in the lcd TextField at the top of the window
(Figure 6-39). As the user clicks each button, the actionPerformed()
method is executed, and the
label from the button is
concatenated to the
lcd TextField.
clicked
buttons
display
FIGURE 6-39
2. Click the division ( / ) button and then click the 3 button on the keypad.
The number 27 is cleared from the display and is replaced with the number
3 (Figure 6-40). The division button triggers the displayed numbers to be
parsed and calculated. The result is stored in the op1 variable. Internally,
the division button also changes the variable named first to false and the
variable named clearText to true. When the 3 button is clicked, the
clearText value causes the display to clear.
27 cleared
and new
number
displays
division
button
FIGURE 6-40
(continued)
 
Search WWH ::




Custom Search