Java Reference
In-Depth Information
19 @param anAccountNumber
the account number
for this account
20 @param initialBalance
the initial balance
21 */
22
public
BankAccount(
int
anAccountNumber,
double
initialBalance)
23 {
24 accountNumber = anAccountNumber;
25 balance = initialBalance;
26 }
27
28 /**
29
Gets the account number of this bank
account.
30 @return
the account number
31 */
32
public int
getAccountNumber()
33 {
34
return
accountNumber;
35 }
36
37 /**
38
Deposits money into the bank account.
39 @param amount
the amount to deposit
40 */
41
public void
deposit(
double
amount)
42 {
43
double
newBalance = balance + amount;
44 balance = newBalance;
45 }
46
47 /**
48
Withdraws money from the bank account.
49 @param amount
the amount to withdraw
50 */
51
public void
withdraw(
double
amount)
52 {
53
double
newBalance = balance - amount;
54 balance = newBalance;
55 }
56
57 /**
58
Gets the current balance of the bank
account.
59 @return
the current balance
295
296