package turtle;

sub create {
    my $self = {};

    $self->{'-x'} = 0;
    $self->{'-y'} = 0;
    $self->{'-direction'} = 0;
    $self->{'-sin'} = 1;
    $self->{'-cos'} = 0;
    $self->{'-name'} = "akiko";

    bless $self;
    return  $self;
}

sub name {
    my ($self,$name) = @_;
    $self -> {'-name'} = $name;
}

sub forward {
    my ($self) = @_;
    $self->{'-x'}  += $self->{'-cos'};
    $self->{'-y'}  += $self->{'-sin'};
}

sub direction {
    my ($self,$dir) = @_;
    $direction = $dir;
    $self->{'-sin'} = sin($self->{'-direction'} / 360 * 3.141592653 * 2);    
    $self->{'-cos'} = cos($self->{'-direction'} / 360 * 3.141592653 * 2); 
}

sub print {
    my ($self) = @_;
    print "$self->{'-name'} $self->{'-x'} $self->{'-y'}\n";
}

1;
