Пример #1
0
 /**
  * @param Movement $move
  * @return Position
  * return Posizione di Move.
  */
 public function calculateNewPoint(Movement $move)
 {
     $destination = new Position($this->x, $this->y);
     switch ($move->getDirection()) {
         case Movement::NORTH:
             $destination->setY($destination->getY() + $move->getSpeed());
             break;
         case Movement::SOUTH:
             $destination->setY($destination->getY() - $move->getSpeed());
             break;
         case Movement::WEST:
             $destination->setX($destination->getX() - $move->getSpeed());
             break;
         case Movement::EAST:
             $destination->setX($destination->getX() + $move->getSpeed());
             break;
         default:
             throw new \RuntimeException('errore direzione');
     }
     return $destination;
 }