package Animal;
# constructor
sub new {
my $this = {};
# object properties
$this->{DNA} = [];
bless $this;
return $this;
}
sub getDNA
{
my $this = shift;
return "@{$this->{DNA}}";
}
sub setDNA
{
my $this = shift;
@{$this->{DNA}} = @_;
return @{$this->{DNA}};
}
####
package Population;
use Animal;
# constructor
sub new {
my $this = {};
# object properties
$this->{individual} = [];
bless $this;
return $this;
}
sub init {
for ($i=0; $i<5; $i++) {
my $empl = Animal->new();
$empl->setDNA(4, 6, 8, 10);
push (@{$this->{individual}}, $empl);
}
}
####
sub getTheFirst{
my $this = shift;
return @{$this->{individual}}[0]->getDNA();
}