Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.07 KB | None | 0 0
  1. <?php
  2. interface create
  3. {
  4.     function F1();
  5.     function F2();
  6. }
  7.  
  8. class Rectangle implements create
  9. {
  10.     private $a;
  11.     private $b;
  12.  
  13.     function __construct($a, $b) {
  14.         $this->a = $a;
  15.         $this->b = $b;
  16.     }
  17.  
  18.     public function F1() { //perimeter
  19.         $a = $this->a;
  20.         $b = $this->b;
  21.         $p = 2 * $a * $b;
  22.         return $p;
  23.     }
  24.     public function F2() {//lice
  25.         return ($this->a * $this->b);
  26.     }
  27. }
  28.  
  29. class Box implements create
  30. {
  31.     private $a;
  32.     private $b;
  33.     private $c;
  34.  
  35.     function __construct($a, $b, $c) {
  36.         $this->a = $a;
  37.         $this->b = $b;
  38.         $this->c = $c;
  39.     }
  40.  
  41.     public function F1() { //lice
  42.         $a = $this->a;
  43.         $b = $this->b;
  44.         $c = $this->c;
  45.         $s = 2 * ($a * $b + $a * $c + $b * $c);
  46.         return $s;
  47.     }
  48.     public function F2() { //nishto
  49.         return 0;
  50.     }
  51. }
  52.  
  53. $rect = new Rectangle(3, 6);
  54. echo $rect->F1();
  55. echo "<br>";
  56. echo $rect->F2();
  57. echo "<br>";
  58. $box = new Box(2, 3, 4);
  59. echo $box->F1();
  60. echo "<br>";
  61. echo $box->F2();
  62. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement