Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2012
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.08 KB | None | 0 0
  1.     <?php
  2.    
  3.         class geometricObject {
  4.             private $color;
  5.            
  6.             public function __construct($color){
  7.                 $this->color = $color;
  8.             }
  9.            
  10.             public function getColor(){
  11.                 return $color;
  12.             }
  13.            
  14.             public function setColor($color){
  15.                 $this->color = $color;
  16.             }
  17.         }
  18.        
  19.         class circle extends geometricObject {
  20.             private $radius;
  21.            
  22.             public function __construct($radius, $color){
  23.                 parent::__construct($color);
  24.                 $this->radius = $radius;
  25.             }
  26.            
  27.             public function getRadius(){
  28.                 return $radius;
  29.             }
  30.            
  31.             public function getArea(){
  32.                 return (pi() * pow($radius, 2));
  33.             }
  34.            
  35.             public function getSurfaceArea(){
  36.                 return (2 * pi() * $radius);
  37.             }
  38.            
  39.             public function setRadius($radius){
  40.                 $this->radius = $radius;
  41.             }
  42.         }
  43.    
  44.     ?>
  45.  
  46.     <?php
  47.    
  48.         include_once 'templates/classes.php';
  49.    
  50.         $myCircle = new circle(10, "green");
  51.        
  52.         $circleArea = $myCircle->getArea();
  53.        
  54.         $color = $myCircle->getColor();
  55.        
  56.         include_once 'output.php';
  57.    
  58.     ?>
  59.  
  60.     <html>
  61.     <body>
  62.    
  63.     <?php echo $circleArea; echo $color; ?>
  64.    
  65.     </body>
  66.     </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement