예제 #1
0
 public function testInitialValues()
 {
     $point = new Coordinate(1, 2);
     $this->assertFalse($point->isHit());
     $this->assertEquals($point->getPositionX(), 1);
     $this->assertEquals($point->getPositionY(), 2);
 }
예제 #2
0
 /**
  * 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;
 }