SHARE
TWEET

Untitled

a guest Aug 23rd, 2017 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. class Covek{
  3.     private $ime;
  4.     private $prezime;
  5.     private $visina;
  6.     private $tezina;
  7.     private $oci;
  8.     private $kosa;
  9.     private $color = "black";
  10.     private $colorWL = array(
  11.         "red","green","blue"
  12.     );
  13.     function br($broj){
  14.         for($i=0;$i<$broj;$i++){
  15.             echo "<br>";
  16.         }
  17.     }
  18.     public function setColor($color){
  19.         if($color == "random"){
  20.             $this->color = $this->colorWL[rand(0,sizeof($this->colorWL)-1)];
  21.             return;
  22.         }
  23.         if(in_array($color,$this->colorWL)){
  24.             $this->color = $color;
  25.         }
  26.     }
  27.     public function novCovek($ime,$prezime,$visina,$tezina,$oci,$kosa){
  28.         $this->ime = $ime;
  29.         $this->prezime = $prezime;
  30.         $this->visina = $visina;
  31.         $this->tezina = $tezina;
  32.         $this->oci = $oci;
  33.         $this->kosa = $kosa;
  34.     }
  35.     public function draw(){
  36.         echo "<div style='color: ".$this->color.";display: inline;'>" . $this->ime . "</div>";
  37.         echo " ";
  38.         echo "<div style='color: ".$this->color.";display: inline;'>" . $this->prezime . "</div>";
  39.         $this->br(2);
  40.         echo "Visina: " . $this->visina;
  41.         $this->br(1);
  42.         echo "Tezina: " . $this->tezina;
  43.         $this->br(1);
  44.         echo "Oci: " . $this->oci;
  45.         $this->br(1);
  46.         echo "Kosa: " . $this->kosa;
  47.     }
  48. }
  49.  
  50. $c = new Covek;
  51. $c->novCovek("Nikola", "Ranisavljev", "186", "86kg", "braon", "smedja");
  52. $c->setColor("random");
  53. $c->draw();
RAW Paste Data
Top