Sythz

Untitled

Feb 15th, 2020
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.35 KB | None | 0 0
  1. <?php
  2.  
  3.     include 'init.php';
  4.  
  5.      class Manusia implements GayaHidup  {
  6.         private $nama;
  7.         private $gender;
  8.         private $tanggal_lahir;
  9.  
  10.         public function setNama($nama){
  11.             $this->nama = $nama;
  12.         }
  13.         public function getNama(){
  14.             return $this->nama;
  15.         }
  16.  
  17.         public function setGender($gender){
  18.             $this->gender = $gender;
  19.         }
  20.         public function getGender(){
  21.             return $this->gender;
  22.         }
  23.  
  24.         public function setTanggal_lahir($tanggal_lahir){
  25.             $this->tgl_lahir = $tanggal_lahir;
  26.         }
  27.         public function getTanggal_lahir(){
  28.             return $this->tgl_lahir;
  29.         }
  30.  
  31.         public function usia(){
  32.             $date = date_create_from_format("d/m/Y", $this->tgl_lahir);
  33.             $tahun_lahir = $date->format('Y');
  34.             $tahun_sekarang = date('Y');
  35.             $usia = $tahun_sekarang - $tahun_lahir;
  36.             return $usia;
  37.         }
  38.  
  39.         public function berbicara(){
  40.             echo "awoakwoakwoakwoa";
  41.         }
  42.  
  43.         public function bernafas(){
  44.             echo "hmmm.... bau ...";
  45.         }
  46.  
  47.         public function makan(){
  48.             echo "hmmm... daging skubidu";
  49.         }
  50.  
  51.         public function berjalan(){
  52.             echo "Pletak ... pletuk...";
  53.         }
  54.     }
  55.  
  56. ?>
Advertisement
Add Comment
Please, Sign In to add comment