
    package Signal;
    sub new {
        my $type = shift;
        my %params = @_;
        my $self = {};
            $self->{'State'}  = $params{'State'};
        $self->{'State'}  = 
            defined($params{'State'})? $params{'State'}:'red';
        $self->{'States'}  = ['green','yellow','red'];
        bless $self;
    }
    sub next {
        my ($self) = shift;
        my $state = $self->{'State'};
        if($state eq 'red') {
            $self->{'State'} = 'green';
        } elsif($state eq 'green') {
            $self->{'State'} = 'yellow';
        } else {
            $self->{'State'} = 'red';   # Red for all other cases 
        }
        # return $self->{'State'};
    }
    sub print {
        my ($self) = shift;
        my $state = $self->{'State'};
        print $state;
    }

1;
