/**
 * Object
 *
 * Demonstrates usage of an object.
 */

class BankAccount
{
    public method deposit (amount)
    {
        @transactions.add({"type":"deposit", "amount":amount})
        @balance += amount
    }

    public method withdrawal (amount)
    {
        @transactions.add({"type":"withdrawal", "amount":amount})
        @balance -= amount
    }

    public method print_activity ()
    {
        print("account name: " + @name)
        print("account number: " + @number)
        print("account balance: " + @balance)

        print("\ntransactions:\n")

        for (num, txn; @transactions) {
            print(" number: " + num)
            print(" type: " + txn["type"])
            print(" amount: " + txn["amount"])
            print("\n")
        }
    }

    method initialize (name, number, initial_balance)
    {
        field @name = name
        field @number = number
        field @balance = initial_balance
        field @transactions = Array.new()
    }
}

myacct = BankAccount.new("adam", "1234", 100.50)
myacct.deposit(400), myacct.withdrawal(300)
myacct.print_activity()