Exemplo n.º 1
0
 /**
  *
  */
 public function testNew()
 {
     $p1 = new Polygon();
     $this->assertEquals(0, $p1->pointsCount());
     $pt1 = new Point2d();
     $p1->addPoint($pt1);
     $this->assertEquals(1, $p1->pointsCount());
     $pt2 = new Point2d();
     $p1->setPoint(0, $pt2);
     $this->assertEquals(1, $p1->pointsCount());
     $pt3 = new Point2d();
     $p1->setPoint(1, $pt3);
     $this->assertEquals($p1->getPoint(1), $pt3);
 }
Exemplo n.º 2
0
 /**
  * @inheritdoc
  *
  * @param int $index
  * @param Point2d $point
  * @return Rectangle
  * @throws Exception
  */
 public function setPoint($index, Point2d $point)
 {
     if (!in_array($index, array(0, 1, 2, 3))) {
         throw new Exception('I am a rectangle!');
     }
     parent::setPoint($index, $point);
     return $this;
 }
Exemplo n.º 3
0
 /**
  * @inheritdoc
  *
  * @param int $index
  * @param Point2d $point
  * @throws Exception
  */
 public function setPoint($index, Point2d $point)
 {
     if (!in_array($index, array(0, 1, 2))) {
         throw new Exception('I am a triangle!');
     }
     parent::setPoint($index, $point);
 }