Class BankAccount

java.lang.Object
  extended by BankAccount

public class BankAccount
extends java.lang.Object


Constructor Summary
BankAccount()
          Creates a bank account with initial balance 0 and account number 1.
BankAccount(double initBalance, int accountNumber)
          Creates a bank account with the given initial balance and given account number.
 
Method Summary
 void deposit(double amount)
          Deposits funds to the account.
 int getAccountNumber()
          Gets the account number.
 double getBalance()
          Gets the curent account balance.
 int withdraw(double amount)
          Withdraws funds from the account if they are available.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BankAccount

public BankAccount()
Creates a bank account with initial balance 0 and account number 1.


BankAccount

public BankAccount(double initBalance,
                   int accountNumber)
Creates a bank account with the given initial balance and given account number.

Parameters:
initBalance - Initial balance
accountNumber - Account number
Method Detail

getBalance

public double getBalance()
Gets the curent account balance.

Returns:
Current account balance

withdraw

public int withdraw(double amount)
Withdraws funds from the account if they are available. If the withdrawal amount is larger than the balance, this method subtracts the amount from the balance and returns 0. Otherwise, the method leaves the balance unchanged and returns 1. Precondition: amount > 0.

Parameters:
amount - Withdrawal amount
Returns:
Error condition: 0 if successful, 1 if insufficient funds

deposit

public void deposit(double amount)
Deposits funds to the account. Precondition: amount > 0.

Parameters:
amount - Deposit amount

getAccountNumber

public int getAccountNumber()
Gets the account number.

Returns:
Account number