package Person;
use strict;

#
# new is the method used to construct a new object
#

sub new {
    my $class = shift;
    $class = ref($class) || $class;

    my $self = {};         # The new object is represented by a hash
    $self->{NAME} = undef;
    $self->{AGE} = undef;
    $self->{FRIENDS} = [];
    bless ($self, $class); # This says the object $self belongs to the
                           # specified class.
    return $self;
}

#
# methods (behaviors of the object)
# I'm writing these to be setters (set the value) if they get an argument
# or getters (get the value)
#

sub name {
    my $self = shift;
    if (@_) {
	$self->{NAME} = shift;
    }
    return $self->{NAME};
}

sub age {
    my $self = shift;
    if (@_) {
	$self->{AGE} = shift;
    }
    return $self->{AGE};
}

sub friends {
    my $self = shift;
    if (@_) {
	@{ $self->{FRIENDS} } = @_;
    }
    return $self->{FRIENDS};

}

1; # this value is the result of require Person and must be a true value.
