public function testInitialValues() { $point = new Coordinate(1, 2); $this->assertFalse($point->isHit()); $this->assertEquals($point->getPositionX(), 1); $this->assertEquals($point->getPositionY(), 2); }
/** * When adding a new point to a ship, each point should have one * axis of which the values are in sequence. * * Check to see if the new point follows this sequence. * * @param Coordinate $point Point to check * @return boolean True when the point follows sequence, False on failure. */ public function orientatedCoordinateFollowsSequence(Coordinate $point) { $lastPoint = end($this->points); if ($this->orientation === self::ORIENTATION_HORIZONTAL) { $lastValue = $lastPoint->getPositionX(); $newValue = $point->getPositionX(); } else { $lastValue = $lastPoint->getPositionY(); $newValue = $point->getPositionY(); } if ($newValue === $lastValue - 1 || $newValue === $lastValue + 1) { return true; } return false; }