ulvis.paste.net

Paste Search Dynamic
Recent pastes
getName
  1. <?php
  2. class Animal
  3. {
  4.  
  5.   //------------------------
  6.   // MEMBER VARIABLES
  7.   //------------------------
  8.  
  9.   //Animal Attributes
  10.   private $family;
  11.   private $food;
  12.  
  13.   //------------------------
  14.   // CONSTRUCTOR
  15.   //------------------------
  16.  
  17.   public function __construct($aFamily, $aFood)
  18.   {
  19.     $this->family = $aFamily;
  20.     $this->food = $aFood;
  21.   }
  22.  
  23.   //------------------------
  24.   // INTERFACE
  25.   //------------------------
  26.  
  27.   public function setFamily($aFamily)
  28.   {
  29.     $wasSet = false;
  30.     $this->family = $aFamily;
  31.     $wasSet = true;
  32.     return $wasSet;
  33.   }
  34.  
  35.   public function setFood($aFood)
  36.   {
  37.     $wasSet = false;
  38.     $this->food = $aFood;
  39.     $wasSet = true;
  40.     return $wasSet;
  41.   }
  42.  
  43.   public function getFamily()
  44.   {
  45.     return $this->family;
  46.   }
  47.  
  48.   public function getFood()
  49.   {
  50.     return $this->food;
  51.   }
  52.  
  53.   public function equals($compareTo)
  54.   {
  55.     return $this == $compareTo;
  56.   }
  57.  
  58.   public function delete()
  59.   {}
  60.  
  61. }
  62.  
  63. class Person
  64. {
  65.  
  66.   //------------------------
  67.   // MEMBER VARIABLES
  68.   //------------------------
  69.  
  70.   //Person Attributes
  71.   private $name;
  72.   private $nric;
  73.  
  74.   //------------------------
  75.   // CONSTRUCTOR
  76.   //------------------------
  77.  
  78.   public function __construct($aName, $aNric)
  79.   {
  80.     $this->name = $aName;
  81.     $this->nric = $aNric;
  82.   }
  83.  
  84.   //------------------------
  85.   // INTERFACE
  86.   //------------------------
  87.  
  88.   public function setName($aName)
  89.   {
  90.     $wasSet = false;
  91.     $this->name = $aName;
  92.     $wasSet = true;
  93.     return $wasSet;
  94.   }
  95.  
  96.   public function setNric($aNric)
  97.   {
  98.     $wasSet = false;
  99.     $this->nric = $aNric;
  100.     $wasSet = true;
  101.     return $wasSet;
  102.   }
  103.  
  104.   public function getName()
  105.   {
  106.     return $this->name;
  107.   }
  108.  
  109.   public function getNric()
  110.   {
  111.     return $this->nric;
  112.   }
  113.  
  114.   public function equals($compareTo)
  115.   {
  116.     return $this == $compareTo;
  117.   }
  118.  
  119.   public function delete()
  120.   {}
  121.  
  122. }
  123.  
  124. $orang = new Person("ali", "123");
  125. echo $orang ->getName();
  126. echo $orang->setName("abu");
  127. echo $orang->getName();
  128.  
  129. ?>
Parsed in 0.025 seconds