Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.83 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 = "3k", $oceny = [3,4,5,1,2,6,6,4], $przedmioty = ["Matematyka", "Polski", "Angielski"];
  18.        
  19.         function dane(){
  20.             echo $this -> imie ." ".$this -> nazwisko." - ".(array_sum($this -> oceny) / count($this -> oceny));
  21.         }
  22.     }
  23.    
  24.     $ns = new osoba('Adam','Kek',1999);
  25.     $ns2 = new uczen('Krystix', 'Lawl', 1232);
  26.    
  27.     $ns2 -> dane();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement