/**
 * a simple bank account class
 */
public class BankAccount {
   private String owner;
	private double balance;
	
	/**
	 * create a BankAccount
	 * @param owner name of account owner
	 */
	public BankAccount(String owner) {
	   this.owner = owner;
		this.balance = 0.0;
	}
	/**
	 *  return the name of the account owner
	 *  @return account owner
	 */
	public String getOwner() {
	   return this.owner;
	}
	
	/**
	 * return the current balance
	 * @return account balance
	 */
	public double getBalance() {
	   return this.balance;
	}
	
	/**
	 * add money to the account
	 * @param amount deposit amount (must be positive)
	 * @throws IllegalArgumentException if amount is negative
	 */
	public void deposit(double amount) {
	   if (amount>0.0) {
	      this.balance += amount;
		}
		else {
		   throw new IllegalArgumentException("must deposit positive amount");
		}
	}

	/**
	 * withdraw money from the account
	 * @param amount withdrawal amount
	 * @throws IllegalArgumentException when not enough money in account 
	 *         or amount is negative
	 */
	public void withdraw(double amount) {
	   if (amount <= 0.0) {
		   throw new IllegalArgumentException("can only withdraw positive amount!");
		}
	   else if (this.balance >= amount) {
	      this.balance -= amount;
		}
		else {
		   throw new IllegalArgumentException("not enough money in account!");
		}
	}
	
	/**
	 * override built-in toString method
	 * @return account information as String
	 */
	@Override
	public String toString() {
	   return this.owner + ": $" + this.balance;
	}

}