Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Shape;
- use Codeception\Exception\ExtensionException;
- class Circle{
- private static $radius;
- private static $area;
- private static $perimeter;
- public function __construct($num){
- if($num <0)
- {
- throw new \Exception('Cannot create circle with negative radius');
- }
- elseif(is_numeric($num)) {
- self::$radius = $num;
- self::$area = pi() * $num * $num;
- self::$perimeter = 2 * pi() * $num;
- }
- else{
- throw new \Exception('Cannot create circle with non-numeric radius');
- }
- }
- public function radius() {
- return self::$radius;
- }
- public function area(){
- return self::$area;
- }
- public function perimeter(){
- return self::$perimeter;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement