You give the Party class a method that looks for a red table:
Homework: implement this method using grepsub has_red_table { my $self = shift; for (@{ $self->tables }) { return 1 if $_->color eq 'red'; } return 0; }
Also, note that you have a serious typo: "table" is not "tables" ... but Moose should catch that for you. Here is the client that i used to help you as well:
use strict; use warnings; my $table1 = Table->new(size => 'big', color => 'red'); my $table2 = Table->new(size => 'small', color => 'blue'); my $party1 = Party->new( tables => [$table1,$table2] ); my $party2 = Party->new( tables => [$table2,$table2] ); print $party1->has_red_table, $/; print $party2->has_red_table, $/;
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
In reply to Re: Perl Moose, basics
by jeffa
in thread Perl Moose, basics
by Nar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |