Help for this page

Select Code to Download


  1. or download this
    package Location;
    use 5.008001;
    ...
    use constant nl=>"\n";
    use constant X=>0; # these are the array fields
    use constant Y=>1;
    
  2. or download this
    # defaults
    {
    ...
        return $default_location->[Y];
        }
    }
    
  3. or download this
    sub new{
        use integer;
    ...
        $y||get_default_Y
        ],$self;
    }
    
  4. or download this
    sub get_location{
        my $self=shift;
    ...
        my $self=shift;
        return $self->get_location->[Y];
    }
    
  5. or download this
    sub set_location{
        my ($self,$x,$y)=@_;
    ...
    }
    # so far so nice
    1;
    
  6. or download this
    use integer; #we use integer coordinates
    use constant nl=>"\n";
    ...
    use constant Y=>1;
    # overload => thats new !
    use overloead '<=>' => 'compare';
    
  7. or download this
    sub compare {
        my ($loc1,$loc2,$rev)=@_;
    ...
            return 0;
        return ;
    }