#!/usr/bin/env perl use strict; use warnings; #if you've followed the correct procedures from the 2nd Object Oriented #Programming slides, your modules should end up installed in the following #directory. ($ENV{HOME} is the environment variable that contains your #home directory.) #Don't forget the `make install` part of the procedures, or this won't work! use lib "$ENV{HOME}/lib/perl5/site_perl/"; #change the following line to your RCS Id. This is the ONLY change #permissible. After that, this script should run with your modules #without any additional changes use Lallip::BankAccount; #Okay, I lied. You'll obviously have to change this as well. #This creates a new checking account, with my name as the account holder. #Of course, a new account should have a $0.00 balance. my $acct = new Lallip::BankAccount('Paul Lalli', 'checking'); $acct->deposit(100.00); #deposit $100.00 $acct->withdraw(45); #withdraw $45.00 #The following should print "Paul Lalli's checking account: $55.00\n"; $acct->show(); $acct += 20; #deposit $20.00 $acct -= 35.40; #withdraw $35.40; #The following, commented, code is NOT legal, nor supported. #Don't bother trying to code for it #$new_acct = $acct + 50; #$acct = $acct - 25; #see sample output for the results of this method $acct->history(); $acct += 100; #another $100 deposit. $acct->withdraw(50); #withdraw $50 $acct->withdraw(25); #withdraw $25 $acct->deposit(200); #deposit $200 #Average ALL deposits. print "The average of all deposits: ", $acct->deposits(), "\n"; #Skip the first two transactions print "The average of withdrawls starting with the 3rd transaction: ", $acct->withdrawls(3), "\n"; #Now providing a (inclusive) range print "Average deposits, from 2nd through 5th transaction: ", $acct->deposits(2,5), "\n"; #Change the account holder's name, and show the account again: $acct->name('Paul D. Lalli'); $acct->show();