

Creating a Custom Guest Class
In the first chapter, you created individual variables to store a guest's name, e-mail address, and comments. When keeping track of multiple guests, it's more useful to encapsulate all the data for a guest as a single entity. You'll do this by creating a Java class that contains the data for a single guest.- In Project Builder's browser, select Classes in the first column.
- Choose File
New in Project.
- Type Guest.java as the name of the file.
- Click OK.
The newly created file contains a skeleton for a class called Guest.
- Enter the following code to complete the definition of the Guest class.
A class stores information in its instance variables (also referred to as data members). Here you're declaring three instance variables for Guest: name, email, and comments. Note that these declarations are the same as those that appeared in the code for Main.java when you added the three variables using WebObjects Builder. In WebObjects, a component is also a class, specifically a subclass of the class next.wo.Component (called WOComponent in WebScript or Objective-C).
- Save Guest.java.
Saving the file lets WebObjects Builder know about your newly created Guest class.
Table of Contents
Next Section