in reply to Creating Common Constructor
Maybe something like:
I don't know if I agree with your Zoo::Zoo 8-)#---------------------------------------- package Zoo::Animal; use strict; 1; sub new { my $class = shift; my $sref_oid = Zoo::Zoo->_gen_oid(); my $self = { _oid => $$sref_oid, @_ }; bless $self, $class; print "Animal initialised\n"; return $self; } #---------------------------------------- package Zoo::Camel; use strict; use base qw( Zoo::Animal ); sub new { my ( $class ) = @_; my $self = $class->SUPER::new( _type => 'camel', _color => 'grey', _legs => 4, _humps => 2, ); print "Camel initialised\n"; return $self; } #---------------------------------------- package Zoo::Lama; use strict; use base qw( Zoo::Animal ); sub new { my ( $class ) = @_; my $self = $class->SUPER::new( _type => 'lama', _color => 'white', _legs => 4, ); print "Lama initialised\n"; return $self; }
This seems to say to me that a Zoo::Zoo is an Animal, a Camel or a Lama - I would have thought the Zoo is more like a container of Animals, rather than an actual beastie?package Zoo::Zoo; use UUID; use lib '.'; use base qw( Zoo::Animal Zoo::Camel Zoo::Lama );
|
|---|