#!/usr/bin/env perl
package BankAccount;
use Moose;
use Data::Dumper;
has 'balance' => (
is => 'rw',
isa => 'Str',
default => 0
);
sub deposit {
my ($self, $amount) = @_;
$self->balance( $self->balance + $amount);
}
sub showBalance {
my $self = @_;
print "The balance is : \n";
}
my $savingAccount = BankAccount->new( balance => 250 );
print Dumper($savingAccount);
$savingAccount->deposit(100);
print Dumper($savingAccount);
$savingAccount->showBalance();
2013年3月12日
[Perl] Moose 範例 - 銀行篇
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言