/** * @param Rover $rover * @throws \Exception */ public function addRover(Rover $rover) { if (!$this->validateCoordinates($rover->getX(), $rover->getY())) { throw new \Exception(sprintf('Rover\'s coordinates (%d:%d) are not valid', $rover->getX(), $rover->getY())); } $this->rovers[] = $rover; $rover->setRoverListener($this); }