Apple WebObjects 3.5 Manual de usuario Pagina 41

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 120
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 40
Creating a Custom Guest Class
41
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.
1. In Project Builder’s browser, select Classes in the first column.
2. Choose File
m New in Project.
3. Type
Guest.java as the name of the file.
4. Click OK.
The newly created file contains a skeleton for a class called Guest.
5. 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
Type name of class here.
Add your class’s
instance variables.
Add constructor for
Guest class.
Vista de pagina 40
1 2 ... 36 37 38 39 40 41 42 43 44 45 46 ... 119 120

Comentarios a estos manuales

Sin comentarios