Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- interface create
- {
- function F1();
- function F2();
- }
- class Rectangle implements create
- {
- private $a;
- private $b;
- function __construct($a, $b) {
- $this->a = $a;
- $this->b = $b;
- }
- public function F1() { //perimeter
- $a = $this->a;
- $b = $this->b;
- $p = 2 * $a * $b;
- return $p;
- }
- public function F2() {//lice
- return ($this->a * $this->b);
- }
- }
- class Box implements create
- {
- private $a;
- private $b;
- private $c;
- function __construct($a, $b, $c) {
- $this->a = $a;
- $this->b = $b;
- $this->c = $c;
- }
- public function F1() { //lice
- $a = $this->a;
- $b = $this->b;
- $c = $this->c;
- $s = 2 * ($a * $b + $a * $c + $b * $c);
- return $s;
- }
- public function F2() { //nishto
- return 0;
- }
- }
- $rect = new Rectangle(3, 6);
- echo $rect->F1();
- echo "<br>";
- echo $rect->F2();
- echo "<br>";
- $box = new Box(2, 3, 4);
- echo $box->F1();
- echo "<br>";
- echo $box->F2();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement