Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class geometricObject {
- private $color;
- public function __construct($color){
- $this->color = $color;
- }
- public function getColor(){
- return $color;
- }
- public function setColor($color){
- $this->color = $color;
- }
- }
- class circle extends geometricObject {
- private $radius;
- public function __construct($radius, $color){
- parent::__construct($color);
- $this->radius = $radius;
- }
- public function getRadius(){
- return $radius;
- }
- public function getArea(){
- return (pi() * pow($radius, 2));
- }
- public function getSurfaceArea(){
- return (2 * pi() * $radius);
- }
- public function setRadius($radius){
- $this->radius = $radius;
- }
- }
- ?>
- <?php
- include_once 'templates/classes.php';
- $myCircle = new circle(10, "green");
- $circleArea = $myCircle->getArea();
- $color = $myCircle->getColor();
- include_once 'output.php';
- ?>
- <html>
- <body>
- <?php echo $circleArea; echo $color; ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement