Java Reference
In-Depth Information
method declaration; it takes on the value of the actual parameter so that
it can be used inside the method.
SR 4.21
The following code implements the requested getFaceDown method.:
//---------------------------------------------------
// Face down value accessor.
//---------------------------------------------------
public int getFaceDown()
{
return (MAX + 1) - faceValue;
}
SR 4.22
In the Transactions program
a. Three Account objects are created.
b. Two arguments (actual parameters) are passed to the withdraw
method when it is invoked on the acct2 object.
c. No arguments (actual parameters) are passed to the addInterest
method when it is invoked on the acct3 object.
SR 4.23
The method getBalance is a classic accessor method. One can also classify
the toString method as an accessor, since it returns information about the
object. The deposit , withdraw , and addInterest methods all provide both
mutator and accessor capabilities, because they can be used to change the
account balance and also return the value of the balance after the change
is made. All of the methods mentioned above are service methods--they all
have public visibility and provide a service to the client.
4.5 Constructors Revisited
SR 4.24
Constructors are special methods in an object that are used to initialize
the object when it is instantiated.
SR 4.25
A constructor has the same name as its class, and it does not return a
value.
4.6 Graphical Objects
SR 4.26
The “content” of the panel created in the SmilingFace program is
defined in the SmilingFacePanel class.
SR 4.27
In the SmilingFace program, the paintComponent method of the panel
object is invoked automatically when the panel object SmilingFacePanel
is instantiated.
Search WWH ::




Custom Search