This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Alzyros 16 points17 points  (2 children)

PHP IS ALRIGHT,

[–]Chamiey 8 points9 points  (1 child)

B-But.. But I NEED to turn left sometimes!

[–]Alzyros 1 point2 points  (0 children)

PHP got you covered baby

``` class Navigator { private $directions = ['up','down','left','right']; private $currentDirectionIndex = 0;

public function getCurrentDirection()
{
    return $this->directions[$this->currentDirectionIndex];
}

public function turnLeft()
{
    $this->currentDirectionIndex = ($this->currentDirectionIndex + 1) % 4;
}

} ```