Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.02 KB | None | 0 0
  1. <?php
  2.     class osoba {
  3.         protected $imie,$nazwisko,$rok_urodzenia;
  4.        
  5.         function __construct($i,$n,$r){
  6.             $this -> imie = $i;
  7.             $this -> nazwisko = $n;
  8.             $this -> rok_urodzenia = $r;
  9.         }
  10.        
  11.         function dane(){
  12.             echo $this -> imie ." ".$this -> nazwisko." - ".(date("Y") - $this -> rok_urodzenia);
  13.         }
  14.     }
  15.    
  16.     class uczen extends osoba {
  17.         private $klasa, $oceny, $przedmioty;
  18.        
  19.        function __construct($i,$n,$r,$k,$o,$p){
  20.            parent::__construct($i,$n,$r);
  21.            $this -> klasa = $k;
  22.            $this -> oceny = $o;
  23.            $this -> przedmioty = $p;
  24.        }
  25.        
  26.         function dane(){
  27.             echo $this -> imie ." ".$this -> nazwisko." - ".(array_sum($this -> oceny) / count($this -> oceny));
  28.         }
  29.     }
  30.    
  31.     $ns = new osoba('Adam','Kek',1999);
  32.     $ns2 = new uczen('Krystix', 'Lawl',1233,'3k',[3,4,5,1,2,6,6,4],["Matematyka", "Polski", "Angielski"]);
  33.    
  34.     $ns2 -> dane();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement