bank
Class Account

java.lang.Object
  |
  +--bank.Account
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable

public class Account
extends java.lang.Object
implements java.lang.Comparable, java.lang.Cloneable


Field Summary
protected  IDs.Id acctNum
           
protected  double balance
           
protected  java.lang.String PIN
           
 
Constructor Summary
Account()
          Creates a new instance of Account takes defaults for balance (0) and interest rate, but no value for acct number
Account(java.lang.String pin, double bal)
          Creates a new instance of Account - with random acct number and other given info about the account
Account(java.lang.String acct, java.lang.String pin, double bal)
          Creates a new instance of Account - given info about the account
 
Method Summary
 int compareTo(java.lang.Object obj)
          Compares two accounts - needed for sorting - required since implements Comparable interface Don't show until we cover interfaces returns negative if object comparing to is less, zero if object comparing to is equal, positive if object comparing to is greater MAR - I have made the call that accounts should be compared based on their acct number
 boolean deposit(double amt)
          deposit a given amount into the calling Account
 double depositEx(double amt)
          deposit a given amount into the calling Account returns the new balance Exception Handling version - do not show until exception handling covered
 boolean equals(bank.Account toCompare)
          determine if a passed account has the same contents as the calling object (account number, PIN, AND balance) Overrides version in java.lang.Object
 IDs.Id getAcctID()
          return the account number as an ID
 java.lang.String getAcctNum()
          return the account number as a string
 double getBal()
          return the current balance - basically an account inquiry
 java.lang.String getPin()
          report the PIN
static void main(java.lang.String[] args)
           
 boolean matchAcctNum(bank.Account toCompare)
          determine if a passed account has the same account number as the calling object (does not worry about whether the id matches on required length or whether there is a check digit - if the string matches, this matches
 boolean matchAcctNum(java.lang.String toCompare)
          determine if a passed string is the correct account number for the calling object
 boolean setAcctId(IDs.Id acctNumber)
          set account number, given an id - should probably only be used publically at the creation of the account.
 boolean setAcctNum(java.lang.String acctNumber)
          set account number, given a string - should probably only be used publically at the creation of the account.
 boolean setBal(double amt)
          set the account balance - should probably only be used publicly at the creation of the account.
 boolean setPIN(java.lang.String pin)
          set PIN - should be carefully controlled
 java.lang.String toString()
          produce a string for an account - generally used for display Overrides version in java.lang.Object
 boolean withdraw(double amt)
          withdraw a given amount from the calling Account
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

acctNum

protected IDs.Id acctNum

PIN

protected java.lang.String PIN

balance

protected double balance
Constructor Detail

Account

public Account()
Creates a new instance of Account takes defaults for balance (0) and interest rate, but no value for acct number


Account

public Account(java.lang.String pin,
               double bal)
Creates a new instance of Account - with random acct number and other given info about the account


Account

public Account(java.lang.String acct,
               java.lang.String pin,
               double bal)
Creates a new instance of Account - given info about the account

Method Detail

deposit

public boolean deposit(double amt)
deposit a given amount into the calling Account


depositEx

public double depositEx(double amt)
                 throws bank.NegativeAmount
deposit a given amount into the calling Account returns the new balance Exception Handling version - do not show until exception handling covered

bank.NegativeAmount

withdraw

public boolean withdraw(double amt)
withdraw a given amount from the calling Account


getBal

public double getBal()
return the current balance - basically an account inquiry


getAcctNum

public java.lang.String getAcctNum()
return the account number as a string


getAcctID

public IDs.Id getAcctID()
return the account number as an ID


getPin

public java.lang.String getPin()
report the PIN


setBal

public boolean setBal(double amt)
set the account balance - should probably only be used publicly at the creation of the account. All other accesss to changing the balance should be handled through deposit or withdraw


setAcctId

public boolean setAcctId(IDs.Id acctNumber)
set account number, given an id - should probably only be used publically at the creation of the account.


setAcctNum

public boolean setAcctNum(java.lang.String acctNumber)
set account number, given a string - should probably only be used publically at the creation of the account.


setPIN

public boolean setPIN(java.lang.String pin)
set PIN - should be carefully controlled


matchAcctNum

public boolean matchAcctNum(java.lang.String toCompare)
determine if a passed string is the correct account number for the calling object


matchAcctNum

public boolean matchAcctNum(bank.Account toCompare)
determine if a passed account has the same account number as the calling object (does not worry about whether the id matches on required length or whether there is a check digit - if the string matches, this matches


equals

public boolean equals(bank.Account toCompare)
determine if a passed account has the same contents as the calling object (account number, PIN, AND balance) Overrides version in java.lang.Object


toString

public java.lang.String toString()
produce a string for an account - generally used for display Overrides version in java.lang.Object

Overrides:
toString in class java.lang.Object

compareTo

public int compareTo(java.lang.Object obj)
Compares two accounts - needed for sorting - required since implements Comparable interface Don't show until we cover interfaces returns negative if object comparing to is less, zero if object comparing to is equal, positive if object comparing to is greater MAR - I have made the call that accounts should be compared based on their acct number

Specified by:
compareTo in interface java.lang.Comparable

main

public static void main(java.lang.String[] args)
Parameters:
args - the command line arguments little test driver