Imported Robodoc.
[robodoc.git] / Examples / PerlExample / Source / Box / SquareBox.pm
1 #!/usr/bin/perl -w
2
3 #****c* Box/SquareBox
4 # FUNCTION
5 #   A box with the property that are sides are equal.
6 # ATTRIBUTES
7 #   SIDE_LENGTH -- the length of each side
8 # DERIVED FROM
9 #   Box
10 # SOURCE
11
12 package SquareBox;
13
14 use Box;
15 use vars ('@ISA');
16 @ISA = ("Box");
17
18 sub new {
19     my $classname = shift;
20     my $self      = $classname->SUPER::new(@_);
21     $self->{SIDE}  = 1;
22     return $self;
23 }
24
25 #*******
26
27
28 #****m* Box/SquareBox::side
29 # FUNCTION
30 #   Set or get the side length of the square box.
31 # SYNOPSIS
32 #   $boxref->side(100.25);
33 #   my $length = $boxref->side();
34 # RETURN VALUE
35 #   The volume of the box
36 # SOURCE
37
38 sub side {
39     my $self = shift;
40     if (@_) {
41         my $length = shift;
42         $self->{SIDE} = $length;
43     }
44     return  $self->{SIDE};
45 }
46
47 #*******
48
49 #****m* Box/SquareBox::volume
50 # FUNCTION
51 #   Compute the volume of a square box.
52 # SYNOPSIS
53 #   my $volume = $boxref->volume();
54 # RETURN VALUE
55 #   The volume of the box
56 # SOURCE
57
58 sub volume {
59     my $self = { };
60     return $self{SIDE} * $self{SIDE} * $self{SIDE} ;
61 }
62
63 #*****
64 1;
65