Java Reference
In-Depth Information
After the actionPerformed() method is executed, a clearFields() method will
reset all of the input values so that the user can enter a reservation for the next
customer.
The Rooms class creates a room object. Figure 5-5 displays an object-
structure diagram that illustrates the attributes and methods of the Rooms
object.
:Button
Rooms()
name
Number of nonsmoking rooms
Number of smoking rooms
Array of available rooms
data and attributes
bookRoom()
Rooms()
methods
FIGURE 5-5
As shown in Table 5-5, the Rooms class will use two methods, each of which
accepts passed parameters and returns a value. The Rooms() constructor method
allows driver classes to create instances of the Rooms object. The bookRoom()
method allows driver classes to book each room.
Table 5-5
Methods for the Rooms Class
PARAMETERS PASSED
METHOD NAME
TO METHOD
RETURN VALUE
PURPOSE
Rooms()
int non
Has no return data type but
A constructor method called by
int sm
creates a Rooms object internally
driver classes to create an instance
of an array of rooms, identifying
through passed parameters the
number of nonsmoking and
smoking rooms in the array
bookRoom()
boolean smoking
A method that returns an int
An instance method called by driver
classes to obtain a room number
(zero for no room available)
 
Search WWH ::




Custom Search