Ancient

 view release on metacpan or  search on metacpan

t/lib/Cat.pm  view on Meta::CPAN

package Cat;
use strict;
use warnings;
use parent 'Animal';
use slot qw(indoor lives_remaining);

sub new {
    my ($class, %args) = @_;
    my $self = $class->SUPER::new(%args, species => 'cat');
    indoor($args{indoor} // 1);
    lives_remaining($args{lives_remaining} // 9);
    return $self;
}

sub meow {
    return "Meow! I am " . main::name();
}

sub lose_life {

t/lib/Dog.pm  view on Meta::CPAN

package Dog;
use strict;
use warnings;
use parent 'Animal';
use slot qw(breed is_good_boy);

sub new {
    my ($class, %args) = @_;
    my $self = $class->SUPER::new(%args, species => 'dog');
    breed($args{breed}) if exists $args{breed};
    is_good_boy($args{is_good_boy} // 1);  # All dogs are good boys by default
    return $self;
}

sub bark {
    return "Woof! My name is " . main::name();
}

sub describe {
    my $self = shift;
    my $base = $self->SUPER::describe();
    return $base . " (" . (breed() // 'mixed') . " breed)";
}

1;

t/lib/DoubleCounter.pm  view on Meta::CPAN

package DoubleCounter;
use strict;
use warnings;
use parent 'Counter';
use slot qw(multiplier);

sub new {
    my ($class, $mult) = @_;
    my $self = $class->SUPER::new();
    multiplier($mult // 2);
    return $self;
}

sub increment {
    my $self = shift;
    my $mult = multiplier();
    for (1..$mult) {
        $self->SUPER::increment();
    }
    return Counter::count();
}

1;



( run in 2.230 seconds using v1.01-cache-2.11-cpan-0bb4e1dffa6 )