Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head lang="pl-PL">
- <meta charset="utf-8">
- <title></title>
- </head>
- <body>
- <?php
- class Kwadrat{
- public $a;
- private $e;
- private $pole;
- private $obw;
- public function liczpole(){
- $this->pole=$this->a*$this->a;
- echo "Pole kwadratu wynosi P=$this->pole<br/>";
- return $this->pole;
- }
- public function liczobw(){
- $this->obw=$this->a*4;
- echo "Obwód kwadratu wynosi Obw=$this->obw<br/>";
- return $this->obw;
- }
- public function licze(){
- $this->e=sqrt(2)*$this->a;
- echo "Przekątna kwadratu wynosi e=$this->e<br/>";
- return $this->e;
- }
- function __construct($a=0){
- if($a!=NULL){
- $this->a=$a;
- echo "Utworzono kwadrat o boku $this->a<br/>";
- }
- else "Nie podano długości boku!<br/>";
- }
- function __destruct(){
- echo "Obiekt z klasy kwadrat rozjeba..yy..zniszcony";
- }
- }
- $kwadrat=New Kwadrat($_GET['bok_a']);
- //$kwadrat->a=4;
- echo "Bok kwadratu a=$kwadrat->a<br/>";
- $kwadrat->liczpole();
- $kwadrat->liczobw();
- $kwadrat->licze();
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement