Advertisement
Guest User

Untitled

a guest
Nov 28th, 2015
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.84 KB | None | 0 0
  1. <?php
  2. namespace Shape;
  3.  
  4. use Codeception\Exception\ExtensionException;
  5.  
  6. class Circle{
  7.  
  8.     private static $radius;
  9.     private static $area;
  10.     private static $perimeter;
  11.  
  12.     public function __construct($num){
  13.         if($num <0)
  14.         {
  15.             throw new \Exception('Cannot create circle with negative radius');
  16.         }
  17.         elseif(is_numeric($num)) {
  18.             self::$radius = $num;
  19.             self::$area = pi() * $num * $num;
  20.             self::$perimeter = 2 * pi() * $num;
  21.         }
  22.         else{
  23.             throw new \Exception('Cannot create circle with non-numeric radius');
  24.         }
  25.     }
  26.  
  27.     public function radius() {
  28.         return self::$radius;
  29.     }
  30.  
  31.     public function area(){
  32.         return self::$area;
  33.     }
  34.  
  35.     public function perimeter(){
  36.         return self::$perimeter;
  37.     }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement