#!perl
# in a file: Inherit.pm
=head1 NAME
Inherit - Inherit from BaseObj Class for the home and region,
Add the team and town.
=head1 SYNOPSIS
use Inherit;
=head1 DESCRIPTION
Inherit keeps track of the team and town.
=head1 USAGE
my $more = Inherit->more;
# Show the defaults of the San Diego Padres
print $more->go;
# Change to the New York Mets
$more->team("Mets");
$more->town("New York");
$more->home("New York");
$more->region("East Coast");
print $more->go;
print $more->where;
=head1 BUGS
none.
=head1 AUTHOR
David Scott
=head1 METHODS
Methods follow for the Inherit class:
=over 4
=cut
use strict;
use warnings;
package Inherit;
use base qw/BaseObj/; # It can't be that easy, can it?
use fields qw/town team/;
=item my $more = Inherit->new;
This is an object Constructor.
Create an inherit object which defaults to the
team of Padres and the town, San Diego.
=cut
sub new {
my ($self) = shift;
unless ( ref($self) ) {
$self = $self->SUPER::new($self);
}
$self->{town} = "San Diego";
$self->{team} = "Padres";
return $self;
}
=item $more->go;
Return a string which says where I'm going and
adds the town and team.
=cut
sub go {
my ($self) = @_;
return $self->SUPER::go . $self->where;
}
=item $more->where;
show where this team is home to
=cut
sub where {
my ($self) = @_;
return $self->{town} . " is home to the " . $self->{team} . "\n";
}
=back
=cut
1; # enables Perl to know it loaded properly