Java Reference
In-Depth Information
32 }
33
34 /**
35
Withdraws money from the bank
account.
36 @param amount
the amount to withdraw
37 */
38
public void
withdraw(
double
amount)
39 {
40
double
newBalance = balance -
amount;
41 balance = newBalance;
42 }
43
44 /**
45
Gets the current balance of the
bank account.
46 @return
the current balance
47 */
48
public double
getBalance()
49 {
50
return
balance;
51 }
52
53
private double
balance;
54 }
S
ELF
C
HECK
9.
The
Rectangle
class has four instance fields:
x
,
y
,
width
, and
height
. Give a possible implementation of the
getWidth
method
10.
Give a possible implementation of the
translate
method of the
Rectangle
class.
98
99
H
OW
T
O
3.1: Implementing a Class
This is the first of several ȒHow Toȓ sections in this topic. Users of the Linux
operating system have how to guides that give answers to the common questions
ȒHow do I get started?ȓ and ȒWhat do I do next?ȓ. Similarly, the How To sections
in this topic give you step-by-step procedures for carrying out specific tasks.