Java Reference
In-Depth Information
Program Development
The program development cycle for the Calculator application consists of tasks
that correspond to the six development cycle phases, as shown in Table 6-1.
Table 6-1 Calculator Application Development Tasks
DEVELOPMENT PHASE
TASK(S)
1
Analyze the requirements
Analyze the Calculator problem.
2
Design the solution
Design the user interface for the application
and the menu, including placement of the
components. Design the logic to make the
calculator and its menu work.
3
Validate the design
Confirm with the user that the design solves the
problem in a satisfactory manner.
4
Implement the design
Translate the design into code. Include internal
documentation (comments and remarks) within
the code that explains the purpose of the code
statements.
5
Test the solution
Test the program by trying each operator button
and each menu option. Find and correct any
errors (debug) until it is error-free.
6
Document the solution
Print copies of the application code.
Analysis and Design
Figure 6-2 on the next page shows the requirements document that initiates
the development cycle for the Calculator application. The requirements docu-
ment specifies the reason for the request and describes the features required in
the Calculator application.
PROBLEM ANALYSIS A software engineering company wants a Calculator
application written in Java with a small set of menu options, including com-
mands to cut and paste. In order to make the calculator as user-friendly as
possible, it should display in a standard window with Minimize, Maximize, and
Close buttons. In addition, the user should be able to resize the window by drag-
ging its border. As shown in Figure 6-1, the calculator should have ten numeric
buttons (numbered 0-9), four operator buttons, a decimal point, and an equal
button. When the user clicks a numeric button, the digits should display at the
top of the window in a small area similar to an LCD screen on a handheld calcu-
lator. When the user clicks an operator button, such as addition (+) or subtrac-
tion (-), the program should clear the display and allow for the next operand.
The program will need to remember the operands and the operators as the user
enters them in order to perform the calculation correctly. When the user clicks
the equal button, the calculator should display the answer at the top of the
window.
 
Search WWH ::




Custom Search