} public function getY2() { return $this->y2; } public function display() { parent::display(); echo "x2=" . $this->x2 . "</br>"; echo "y2=" . $this->y2 . "</br>"; } } $l = new Line(); $l->setX1(24); $l->setY1(3); $l->setX2(4); $l->setY2(56); $l->display(); class Triangle extends Line { protected $x3; protected $y3; public function setX3($x3) { settype($x3, "integer"); $this->x3 = $x3; } public function getX3() { return $this->x3; }
<?php require 'line.php'; $line = new Line(); $line->setX1(10); $line->setY1(25); $line->setX2(45); $line->setY2(75); $line->drawAndMoveLine(10); $line->displayImage();