// Account.java: The class for descrining an account
public class Account
{
  // Two data fields in an account
  private int ID;
  private double balance;

  // Construct an account with specified ID and balance
  public Account(int ID, double balance)
  {
    this.ID = ID;
    this.balance = balance;
  }

  // Getter method for ID
  public int getID()
  {
    return ID;
  }

  // Setter method for balance
  public void setBalance(double balance)
  {
    this.balance = balance;
  }

  // Getter method for balance
  public double getBalance()
  {
    return balance;
  }

  // Deposit an amount to this account
  public void deposit(double amount)
    throws NegativeAmountException
  {
    if (amount < 0)
      throw new NegativeAmountException
        (this, amount, "deposit");
    balance = balance + amount;
  }

  // Withdraw an amount from this account
  public void withdraw(double amount)
    throws NegativeAmountException, InsufficientFundException
  {
    if (amount < 0)
      throw new NegativeAmountException
        (this, amount, "withdraw");
    if (balance < amount)
      throw new InsufficientFundException(this, amount);
    balance = balance - amount;
  }
}
