Advertisement
zukars3

Untitled

Apr 20th, 2020
536
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.57 KB | None | 0 0
  1. <?php
  2.  
  3. interface ShapeInterface
  4. {
  5.     public function area(): int;
  6. }
  7.  
  8. class Rectangle implements ShapeInterface
  9. {
  10.     private $a;
  11.     private $b;
  12.  
  13.     public function __construct($a, $b)
  14.     {
  15.         $this->a = $a;
  16.         $this->b = $b;
  17.     }
  18.  
  19.     public function area(): int
  20.     {
  21.         return $this->a * $this->b;
  22.     }
  23. }
  24.  
  25. class Triangle implements ShapeInterface
  26. {
  27.     private $r;
  28.  
  29.     public function __construct($r)
  30.     {
  31.         $this->r = $r;
  32.     }
  33.  
  34.     public function area(): int
  35.     {
  36.         return pi() * pow($this->r, 2);
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement