use strict;
use warnings;
{
package Banner;
use strict;
use warnings;
sub new {
my ($class, $string) = @_;
my $self = {
string => $string,
};
return bless $self, $class;
}
sub showWithParen {
my $self = shift;
print "(".$self->{string}.")";
}
sub showWithAster {
my $self = shift;
print "*".$self->{string}."*";
}
}
{
package Interface::Print;
use strict;
use warnings;
sub printWeak { die ""; }
sub printStrong { die ""; }
}
{
package printBanner;
use strict;
use warnings;
our @ISA = qw/Banner Interface::Print/;
sub new {
my ($class, $string) = @_;
my $self = {
string => $string,
super => Banner->new($string),
};
return bless $self, $class;
}
sub printWeak {
my $self = shift;
$self->{super}->showWithParen();
}
sub printStrong {
my $self = shift;
$self->{super}->showWithAster();
}
}
my $p = printBanner->new('hoge');
$p->printWeak();