|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectAccount
public class Account
A class for representing bank accounts.
Field Summary | |
---|---|
(package private) long |
accountNumber
Unique identifying number for an instance of Account . |
(package private) double |
balance
Current balance in this instance of Account . |
(package private) double |
initialBalance
Original balance when this instance of Account
was constructed. |
(package private) static long |
nextAccountNumber
Lowest unused account number, for generating unique identifying numbers for instances of Account . |
(package private) java.lang.String |
owner
Name of the owner of an instance of Account . |
Constructor Summary | |
---|---|
Account(java.lang.String name,
double init_bal)
Creates an instance of Account , with it's own account number. |
Method Summary | |
---|---|
double |
deposit(double amount)
Add an amount to the balance. |
long |
getAccountNumber()
Retrieve the account number. |
double |
getBalance()
Retrieve the current balance. |
double |
getInitialBalance()
Retrieve the original balance. |
java.lang.String |
getOwner()
Retrieve the owner. |
java.lang.String |
toString()
Returns a string representation of this object. |
double |
withdraw(double amount)
Remove an amount from the balance. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
static long nextAccountNumber
Account
.
double balance
Account
.
double initialBalance
Account
was constructed.
long accountNumber
Account
.
java.lang.String owner
Account
.
Constructor Detail |
---|
public Account(java.lang.String name, double init_bal)
Account
, with it's own account number.
name
- The name of the ownerinit_bal
- The initial balanceMethod Detail |
---|
public double getBalance()
balance
public double getInitialBalance()
initialBalance
public long getAccountNumber()
accountNumber
public java.lang.String getOwner()
owner
public double deposit(double amount)
amount
- Non-negative amount to add
balance
after addition
java.lang.IllegalArgumentException
- Thrown if amount
is negativepublic double withdraw(double amount)
amount
- Non-negative amount to subtract
balance
after subtraction
java.lang.IllegalArgumentException
- Thrown if amount
is negativepublic java.lang.String toString()
toString
in class java.lang.Object
Account
.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |