FileDocCategorySizeDatePackage
Account.javaAPI DocExample2349Thu Jun 27 19:20:22 BST 2002com.oreilly.mock

Account

public class Account extends Object

Fields Summary
public static final int
CHECKING
public static final int
SAVINGS
private int
acctType
private String
acctNumber
private double
balance
private PropertyChangeSupport
changes
static NumberFormat
numFormat
Constructors Summary
public Account(int acctType, String acctNumber, double balance)


     
        numFormat.setGroupingUsed(false); // turn off commas
        numFormat.setMinimumFractionDigits(2);
        numFormat.setMaximumFractionDigits(2);
    
        this.acctType = acctType;
        this.acctNumber = acctNumber;
        this.balance = balance;
    
Methods Summary
public voidaddPropertyChangeListener(java.beans.PropertyChangeListener l)

        this.changes.addPropertyChangeListener(l);
    
static java.lang.StringbalanceToString(double balance)

        return numFormat.format(balance);
    
public java.lang.StringgetAccountNumber()

        return this.acctNumber;
    
public intgetAccountType()

        return this.acctType;
    
public doublegetBalance()

        return this.balance;
    
public voidremovePropertyChangeListener(java.beans.PropertyChangeListener l)

        this.changes.removePropertyChangeListener(l);
    
public voidsetBalance(double balance)

        Double oldBalance = new Double(this.balance);
        this.balance = balance;
        this.changes.firePropertyChange("balance",
                oldBalance, new Double(balance));
    
static java.lang.StringtypeToString(int acctType)

        switch (acctType) {
            case CHECKING:
                return "CHECKING";
            case SAVINGS:
                return "SAVINGS";
            default:
                throw new IllegalArgumentException(
                        "Unknown account type: " + acctType);
        }
    
public voidwriteCsv(java.io.PrintWriter pw)

        pw.print(typeToString(this.acctType));
        pw.print(",");
        pw.print(this.acctNumber);
        pw.print(",");
        pw.print(balanceToString(this.balance));