PART I
C h a p t e r 6 :
I n t r o d u c i n g C l a s s e s a n d O b j e c t s
117
PART IPART I
and identifier pairs separated by commas. Parameters are variables that receive the value of
the
arguments
passed to the method when it is called. If the method has no parameters, then
the parameter list will be empty.
Add a Method to the Building Class
As just explained, the methods of a class typically manipulate and provide access to the
data of the class. With this in mind, recall that
Main( )
in the preceding examples computed
the area-per-person by dividing the total area by the number of occupants. Although
technically correct, this is not the best way to handle this computation. The calculation of
area-per-person is something that is best handled by the
Building
class, itself. The reason
for this conclusion is easy to understand: The area-per-person of a building is dependent
upon the values in the
Do'stlaringiz bilan baham: |