Mon Oct 27, 2008 12:01 am
<?php
class Rectangle {
public $height;
public $width;
public function __construct($width, $height) {
$this->width = $width;
$this->height = $height;
}
public function getArea() {
return $this->height * $this->width;
}
}
class Square extends Rectangle {
public function __construct($size) {
$this->height = $size;
$this->width = $size;
}
public function getArea() {
return pow($this->height, 2);
}
}
$obj = new Square(7);
$a = $obj->getArea();
echo "$a";
?>
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.