O.C.P
This code is following O.C.P?unknown
php
2 years ago
726 B
24
Indexable
<?php
class Game
{
private function move(string $direction)
{
// loop logic that needs a index for different directions
}
private function getIndexFromDirection(int $counter1, int $counter2): int
{
return match ($direction) {
'up' => , // logic
'down' => , // logic
'left' => , // logic
'right' => , // logic
default => , // exception
};
}
public function up()
{
$this->move('up');
}
public function down()
{
$this->move('down');
}
public function left()
{
$this->move('left');
}
public function right()
{
$this->move('right');
}
}
Editor is loading...
Leave a Comment