Aggregate pattern: Difference between revisions

Content deleted Content added
Minor change
Another minor change
Line 31:
 
<source lang="perl">
package Cart::Basket;
@ISA = qw(Cart::Item);
sub query_price {
my $self = shift;
my $contents = $self->{contents};
foreach my $item (@$contents) {
}
}
}
# other query_ routines here...
sub add_item {
my $self = shift;
my $contents = $self->{contents};
my $item = shift; $item->isa('Cart::Item') or die;
push @$contents, $item;
return 1;
}
</source>