Advertisement
ujiajah1

pemrograman OOP - Menyatukan semuanya (II)

Aug 28th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.37 KB | None | 0 0
  1. class Kucing {
  2.   public $lucu = true;
  3.   public $warna;
  4.  
  5.   public function __construct($warna) {
  6.     $this->warna= $warna;
  7.   }
  8.   public function meong(){
  9.     return "Meong...!!";
  10.   }
  11.   public function menyapa(){
  12.     return "Hai, saya si $this->warna.";
  13.   }
  14. }
  15. $putih = new kucing("putih");
  16. $hitam = new kucing("hitam");
  17. echo $hitam->menyapa();
  18. echo $putih->meong();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement