# shapes -- A simple shapes example # # Copyright (C) 1998, Bradley M. Kuhn # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # Please request a copy of the GNU General Public License from the author, # or retrieve it from http://www.gnu.org/copyleft/gpl.html # Alternatively, you can obtain a copy by writing to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # Modified for use in COMP 331, Intermediate Perl 3/31/02 - C.D.Lane use warnings; use strict; package Rectangle; use base qw(Shape); our $VERSION = "0.01"; =head1 NAME Rectangle - Perl Rectangle Shape =head1 SYNOPSIS use Shape; my $rect = new Rectangle(0, 0, 5, 4); $rect->moveTo(5, 7); $rect->draw(); =head1 DESCRIPTION Rectangle "draws" a rectangle and allows you to move it =head1 AUTHOR Bradley M. Kuhn =cut ############################################################################### sub new { my ($class, $x, $y, $width, $height) = @_; my $self = $class->SUPER::new($x, $y); $self->{width} = $width; $self->{height} = $height; return $self; } ############################################################################### sub draw { my ($self) = @_; print "Drawing a Rectangle at ($self->{x}, $self->{y}) ", "with width $self->{width} and height $self->{height}.\n"; return $self; } ############################################################################### sub setWidth { my ($self, $newWidth) = @_; $self->{width} = $newWidth; return $self; } ############################################################################### sub setHeight { my ($self, $newHeight) = @_; $self->{height} = $newHeight; return $self; } ############################################################################### 1;