package Student;
use strict;
use warnings;
use Carp;
use Person;
our @ISA = qw/Person/;

sub new {
    my $class = shift;
    #create the base Person object
    my $self = $class->SUPER::new(@_);
    #set additional attributes:
    carp "No id passed, using undef" unless @_ >= 3;
    $self->{id} = $_[2];

    #Since our base class properly blessed the reference
    #into the first arg of the constructor, there's
    #no need to re-bless it now.  Just return it.
    
    return $self;

}

sub id {
    my $self = shift;
    $self->{id} = shift if @_;
    return $self->{id};
}

sub GPA {
    my $self = shift;
    $self->{GPA} = shift if @_;
    return $self->{GPA};
}

sub status {
    my $self = shift;
    $self->{GPA} >= 65 ? 'passing' : 'failing';
}

1;

__END__

=head1 Name

Student.pm - a simple class to define a Student, based on Person.pm

=head1 Synopsis

 #!/usr/bin/env perl
 use strict;
 use warnings;
 use Student;

 my $s1 = new Student('John Smith', '016-32-9823', '337');
 $s1->name('John Q. Smith');
 my $ss = $s1->SSN();
 my $id = $s1->id();

 $s1->GPA(65.0);
 $s1->show();

 print "Student: $s1 is currently: ", $s1->status(), "\n";
 __END__

=head1 Description

This is a simple class which inherits from Person.  In addition to whatever
properties a Person has, a Student will have an Id and a GPA.

=head2 Subroutines

In addition to any subroutines created by the Person class, the following
subroutines are created for Student objects.

=over 5

=item new

Constructor.  Creates a Person object, and then sets the additional id attribute.
Takes three arguments (the first two defined by Person).

=item id

Id accessor.  Gets and Sets the id.

=item GPA

GPA accessor.  Gets and Sets the GPA.

=item status

Returns whether or not this student is passing or failing.

=back

=head1 See Also

L<Person> class.

=head1 Copyright

Copyright 2009, Paul Lalli.  This file is freely distributed and may be used
or modified for any purposes.  No warranties are expressed or implied.

To contact the author, email lallip AT cs DOT rpi DOT edu

