
import java.util.ArrayList;
import java.util.List;


/**
 *
 * @author Bill Kraynek
 */
public class BankAccount {

    private String accountNumber;
    private double balance;
    private String status;
    private ArrayList<Double> transactions;

    /**
     * Constructs a bank account with a zero balance
     * @param anAccountNumber the account number for this account
     */
    public BankAccount(String anAccountNumber) {
        accountNumber = anAccountNumber;
        balance = 0.0;
        status = "open";
        transactions = new ArrayList<Double>();
    }

    /**
     * Constructs a bank account with a given balance
     * @param anAccountNumber the account number for this account
     * @param initialBalance the initial balance
     */
    public BankAccount(String anAccountNumber, double initialBalance) {
        accountNumber = anAccountNumber;
        balance = initialBalance;
        status = "open";
        transactions = new ArrayList<Double>();
    }

    /**
     * Gets the account number of this bank account.
     * @return the account number
     */
    public String getAccountNumber() {
        return accountNumber;
    }
    
    /**
     * Check the status for open
     * @return true if status is open; false othewise
     */
    public boolean isOpen() {
        return status.equals("open");
    }

    /**
     * Check the status for open
     * @return true if status is open; false othewise
     */
    public boolean isClosed() {
        return status.equals("closed");
    }

    /**
     * Check the status for open
     * @return true if status is open; false othewise
     */
    public boolean isSuspended() {
        return status.equals("suspended");
    } 
    
    /**
     * Gets the status
     * @return the status as a String
     */
    public String getStatus() {
        return status;
    }

    /**
     * Deposits money into the bank account.
     * @param amount the amount to deposit
     */
    public void deposit(double amount) {
        balance = balance + amount;
        transactions.add(amount);
    }

    /**
     * Withdraws money from the bank account
     * @param amount the amount to withdraw
     */
    public void withdraw(double amount) {
        balance = balance - amount;
        transactions.add(-amount);
    }

    /**
     * Gets the current balance of the bank account.
     * @return the current balance
     */
    public double getBalance() {
        return balance;
    }
    
    /**
     * Sets the status to be open
     */
    public void open() {
        status = "open";
    }
    
    /**
     * Sets the status to be open
     */
    public void suspend() {
        status = "suspended";
    }
    
    /**
     * Sets the status to be closed
     */
    public void close() {
        status = "closed";
    }
    
    /**
     * Get the List<String
     * @return
     */
    public List<Double> getTransactions() {
        return transactions;
    }
    /**
     * Overrudes the toString method
     * Returns a string representation of this account and its values. 
     */
    public String toString() {
        return "Account Number: " + accountNumber + "\nBalance :" + balance;
    }
}

