package Gorgon;
use 5.6.1;
use Exporter qw(import);
use strict;
use warnings;
use vars qw($VERSION);
$VERSION = '1.00';
our($Earth, $Air, $Fire, $Water)= (0x0001, 0x0002, 0x0004, 0x0008);
our %elmt_name = (
($Earth, "Earth"), ($Air, "Air"),
($Fire, "Fire"), ($Water, "Water"),
);
sub new
{
my $class = shift;
my $self = {};
$class = "Gorgon::Euryale" if ($class eq "Gorgon");
bless($self, $class);
return $self->_setup();
}
sub element
{
my $self = shift;
$self->{element} = $_ if (scalar @_ > 0);
return $elmt_name{ $self->{element} };
}
package Gorgon::Euryale;
use strict;
use warnings;
use base qw(Gorgon);
sub _setup
{
my $self = shift;
$self->{element} = $Water;
return $self
}
sub transmute
{
my $self = shift;
my $elmt = $self->{element};
if ($elmt == $Water ) {$elmt = $Earth ;}
else {$elmt <<= 1;}
$self->{element} = $elmt;
return $elmt;
}
package Gorgon::Stheno;
use strict;
use warnings;
use base qw(Gorgon);
sub _setup
{
my $self = shift;
$self->{element} = $Earth;
return $self
}
sub transmute
{
my $self = shift;
my $elmt = $self->{element};
if ($elmt == $Earth) {$elmt = $Water;}
else {$elmt >>= 1;}
$self->{element} = $elmt;
return $elmt;
}
1;
####
#/usr/local/perl
use Gorgon;
use strict;
use warnings;
my $walk = Gorgon::Stheno->new();
die "Something bad happened $!" unless ($walk);
for (1..8) { $walk->transmute(); print $walk->element(), "\n"; }
exit(0);
####
package Gorgon;
use 5.6.1;
use Exporter qw(import);
use strict;
no strict qw(subs);
use warnings;
use vars qw($VERSION);
$VERSION = '2.00';
use constant Earth => 0x0001;
use constant Air => 0x0002;
use constant Fire => 0x0004;
use constant Water => 0x0008;
our %elmt_name = (
(Earth, "Earth"), (Air, "Air"),
(Fire, "Fire"), (Water, "Water"),
);
sub new
{
my $class = shift;
my $self = {};
$class = "Gorgon::Euryale" if ($class eq "Gorgon");
bless($self, $class);
return $self->_setup();
}
sub element
{
my $self = shift;
$self->{element} = $_ if (scalar @_ > 0);
return $elmt_name{ $self->{element} };
}
package Gorgon::Euryale;
use strict;
no strict qw(subs);
use warnings;
use base qw(Gorgon);
sub _setup
{
my $self = shift;
$self->{element} = Water;
return $self
}
sub transmute
{
my $self = shift;
my $elmt = $self->{element};
if ($elmt == Water ) {$elmt = Earth ;}
else {$elmt <<= 1;}
$self->{element} = $elmt;
return $elmt;
}
package Gorgon::Stheno;
use strict;
no strict qw(subs);
use warnings;
use base qw(Gorgon);
sub _setup
{
my $self = shift;
$self->{element} = Earth;
return $self
}
sub transmute
{
my $self = shift;
my $elmt = $self->{element};
if ($elmt == Earth) {$elmt = Water;}
else {$elmt >>= 1;}
$self->{element} = $elmt;
return $elmt;
}
1;