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 of zero.
BankAccount(int balance)
          Creates a bank account with the given balance.
 
Method Summary
 void deposit(double amount)
          Deposits the given amount to the account.
 double getBalance()
          Returns the current balance of the account.
 boolean withdraw(double amount)
          Withdraws the given amount from the account and returns true if the resulting balance is positive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BankAccount

public BankAccount(int balance)
Creates a bank account with the given balance.

Parameters:
balance - Initial balance for the account

BankAccount

public BankAccount()
Creates a bank account with initial balance of zero.

Method Detail

deposit

public void deposit(double amount)
Deposits the given amount to the account.

Parameters:
amount - Amount of the deposit

withdraw

public boolean withdraw(double amount)
Withdraws the given amount from the account and returns true if the resulting balance is positive. Leaves the account balance unchanged and returns false if the resulting balance would be negative.

Parameters:
amount - Amount of the withdrawal
Returns:
True if successful, false if unsuccessful

getBalance

public double getBalance()
Returns the current balance of the account.

Returns:
Current balance of the account