⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 squarebox.pm

📁 编程工具:直接从程序代码中的注释 产生软件的文档
💻 PM
字号:
#!/usr/bin/perl -w

#****c* Box/SquareBox
# FUNCTION
#   A box with the property that are sides are equal.
# ATTRIBUTES
#   SIDE_LENGTH -- the length of each side
# DERIVED FROM
#   Box
# SOURCE

package SquareBox;

use Box;
use vars ('@ISA');
@ISA = ("Box");

sub new {
    my $classname = shift;
    my $self      = $classname->SUPER::new(@_);
    $self->{SIDE}  = 1;
    return $self;
}

#*******


#****m* Box/SquareBox::side
# FUNCTION
#   Set or get the side length of the square box.
# SYNOPSIS
#   $boxref->side(100.25);
#   my $length = $boxref->side();
# RETURN VALUE
#   The volume of the box
# SOURCE

sub side {
    my $self = shift;
    if (@_) {
        my $length = shift;
        $self->{SIDE} = $length;
    }
    return  $self->{SIDE};
}

#*******

#****m* Box/SquareBox::volume
# FUNCTION
#   Compute the volume of a square box.
# SYNOPSIS
#   my $volume = $boxref->volume();
# RETURN VALUE
#   The volume of the box
# SOURCE

sub volume {
    my $self = { };
    return $self{SIDE} * $self{SIDE} * $self{SIDE} ;
}

#*****
1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -