/*  CreditCard.java  */

package shopping;

import java.beans.*;
import java.io.Serializable;

public class CreditCard extends Object implements Serializable {
    
    private double balance = 0.00;
    
    public double getBalance() {
        return this.balance;
    }
    
    /* Setter for balance...throws PropertyVetoException if vetoable listener rejects new value */
    public void setBalance(double balance) throws PropertyVetoException {
        double oldBalance = this.balance;
        vcs.fireVetoableChange("balance", new Double (oldBalance), new Double (balance));
        this.balance += balance;
    }
        
    public CreditCard() {
    }

    /* Utility field used by constrained properties. */
    private VetoableChangeSupport vcs =  new VetoableChangeSupport(this);

    /* Adds a VetoableChangeListener to the listener list.  @param l The listener to add. */
    public void addVetoableChangeListener(VetoableChangeListener l) {
        vcs.addVetoableChangeListener (l);
    }

    /* Removes a VetoableChangeListener from the listener list. @param l The listener to remove. */
    public void removeVetoableChangeListener(VetoableChangeListener l) {
        vcs.removeVetoableChangeListener (l);
    }
   
}

