Java Reference
In-Depth Information
Table 5-2
Inputs and Outputs for the Reservations Program
INPUTS
OUTPUTS
Customer name
Visual indicator of room reservation status
(available/reserved)
Phone number with area code
Inputted data for each reserved room
Number in party
Smoking preference
When first executed, the program should display eight available rooms.
As noted in the requirements document in Figure 5-2, party rooms are reserved
during the day for the same evening, which means no permanent data needs to
be stored. The rooms are reserved only for parties of eight or more. The
maximum number of guests per room is 20.
As customers call to make reservations, the user can enter the customer
information into the program and click the Book Room button. The program
then should book the room, change some visual element on the user interface to
indicate the change in room reservation status (from available to reserved), and
display the customer information for the reserved room. The program should be
easily changeable as the restaurant adds more party rooms.
DESIGN THE SOLUTION Once you have analyzed the problem, the next step
is to design the user interface. Only one version of the Reservations program is
created in this chapter: a stand-alone, windowed application that the restaurant
will run on a desktop computer system as it takes reservations. A graphical user
interface (GUI) is appropriate for this application, as the user needs a way to
input data, book a room reservation, and then view a visual representation of
each room and its reservation status, along with the customer information
associated with that room.
Figure 5-3 on the next page shows a storyboard for the Reservations
program. The interface includes eight different TextArea components, one for
each of the eight party rooms at the restaurant. A TextArea component , which
appears as a rectangular box in the interface, displays larger amounts of data
than a TextField. TextArea components have methods to turn on and off the
capability to edit the field directly and to display scroll bars. TextArea compo-
nents also have a setBackground() method, similar to the one used for applets,
which can be used to change the TextArea component's background color.
The Reservations program uses eight TextArea components, in two rows of
four, to provide a visual representation of the party rooms. When the program
runs, the background color of each TextArea component will be set to indicate if
the room is available (light green) or reserved (light red). If a room is reserved,
the corresponding TextArea component will display the customer information.
 
Search WWH ::




Custom Search