public function __construct($newX, $newY, $newKolor, $newR, $newH) { echo "Konstruktor Walca<br>"; parent::__construct($newX, $newY, $newKolor, $newR); $this->setH($newH); }
public function __construct($x, $y, $r) { parent::__construct($x, $y, $r); }
$rec->printShape(); //Square $sq = new Square(); $sq->__construct(10, 40, 0, 5); $sq->printShape(); //Triangle $tri = new Triangle(); $tri->__construct(35, 20, 20, 50, 50, 50); $tri->printShape(); //Oval $oval = new Oval(); $oval->__construct(10, 9, 8); $oval->printShape(); //Circle $circle = new Circle(); $circle->__construct(80, 80, 10); $circle->printShape(); //Demos the getAreas function $shape->getAreas($shape, $rec, $circle); class Shape { /*Due to the nature of random shapes sideLengths does not go into the constructor. numSides will be calculated based on the number of sides entered.*/ public $sideLengths; public $numSides; public $width; public $height; public $rotation; public $perim; public $area;
public function __construct($x, $y, $color, $radius, $height) { parent::__construct($x, $y, $color, $radius); $this->height = is_numeric($height) ? $height : 0; echo "<br>Tworzę obiekt 3D <br>"; echo 'położenie x = ' . $this->getX() . '<br>'; echo 'położenie y = ' . $this->getY() . '<br>'; echo 'kolor ' . $this->getColor() . '<br>'; echo 'promień r = ' . $this->getRadius() . '<br>'; echo 'wysokość = ' . $this->getHeight() . '<br>'; echo '<hr>'; }