Java Reference
In-Depth Information
The program should do the following:
1. Show the customer the above GUI.
2. Let the customer make the selection.
3. When the user clicks on a product, show the customer its cost, and
prompt the customer to enter the money for the product using an
input dialog box, as shown in Figure 8-23.
FIGURE 8-23 Input dialog box to enter money for the candy machine
4. Accept the money from the customer.
5. Make the sale and display a dialog box, as shown in Figure 8-24.
FIGURE 8-24 Output dialog box to show the output of the candy machine
In the first part of this programming example, we designed and implemented the
class es CashRegister and Dispenser . Our final step is to revise the main program
of the first part to create a GUI.
We now describe how to create the candy machine using the class es
CashRegister and Dispenser and the GUI components. When the program
executes, it must display the GUI shown earlier in Figure 8-22.
The GUI contains a window, two labels, and five buttons. The labels and buttons are
placed in the content pane of the window. As you learned in Chapter 6, to create the
MAIN
PROGRAM
Search WWH ::




Custom Search