/**
 * An encapsulation of a "numbered" account with pre-determined
 * tax status
 */
public class Account implements Comparable, Taxable
{
    private double    balance;    
    private int       id;

    private static final double TAX_RATE = 0.2;    
    
    /**
     * Explicit Value Constructor
     *
     * @param id      The ID number for this Account
     * @param balance The opening balance for this account
     */
    public Account(int id, double balance)
    {
       this.id      = id;
       this.balance = balance;       
    }
    
    
    /**
     * Compare this Account to another Account
     * (required by Comparable)
     * 
     * @param other   The other Account
     * @return        -1, 0, or 1 based on a comparison of the balances
     */
    public int compareTo(Object other)
    {
       Account      otherAccount;
       int          result;       

       otherAccount = (Account)other;
       
       result = 0;
       if      (this.balance < otherAccount.balance) result = -1;       
       else if (this.balance > otherAccount.balance) result =  1;       

       return result;       
    }

    /**
     * Get the balance for this Account
     *
     * @return  The balance
     */
    public double getBalance()
    {
       return balance;       
    }
    

    /**
     * Get the tax owed on this Account
     *
     * @return   The tax owed
     */
    public double tax()
    {
       return balance * TAX_RATE;       
    }
    
}
