CHaNStar

a2

Feb 19th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.29 KB | None | 0 0
  1. <?php
  2. spl_autoload_register(function($KelompokMakanan){
  3. include $KelompokMakanan.'.php';
  4. });
  5.  
  6. class Manusia extends KelompokMakanan implements GayaHidup
  7. {
  8.     private $jenis_kelamin;
  9.     private $nama;
  10.     private $tanggal_lahir;
  11.     private $kebangsaan;
  12.     private $nomor;
  13.  
  14.     function setJenis_kelamin($jenis_kelamin){
  15.         $this->jenis_kelamin = $jenis_kelamin;
  16.     }
  17.     function setTanggalLahir($tanggal_lahir){
  18.         $this->tanggal_lahir = $tanggal_lahir;
  19.     }
  20.     function setKebangsaan($kebangsaan){
  21.         $this->kebangsaan = $kebangsaan;
  22.     }
  23.     function setNomor($nomor){
  24.         $this->nomor = $nomor;
  25.     }
  26.  
  27.     function getJenis_kelamin(){
  28.         return $this->jenis_kelamin;
  29.     }
  30.     function getTanggalLahir(){
  31.         return $this->tanggal_lahir;
  32.     }
  33.     function getKebangsaan(){
  34.         return $this->kebangsaan;
  35.     }
  36.     function getNomor(){
  37.         return $this->nomor;
  38.     }
  39.  
  40.  
  41.     public function bersuara()
  42.     {
  43.         echo $this->nama;
  44.     }
  45.  
  46.     public function usia()
  47.     {
  48.         $date = date_create_from_format("d/m/Y", $this->tanggal_lahir);
  49.         $tahunLahir = $date->format('Y');
  50.         $tahunSekarang = date('Y');
  51.         $usia = $tahunSekarang - $tahunLahir;
  52.         return $usia;
  53.     }
  54.      function berbicara(){
  55.         echo $this->kebangsaan;
  56.     }
  57.      function bernafas(){
  58.         $nomor = $this->nomor;
  59.         switch($nomor) {
  60.             case '05': return 'Leader';
  61.             case '06': return 'Humoris';
  62.             case '07': return 'Support';
  63.             case '13': return 'Co Leader';
  64.             case '16': return 'Thinker';
  65.             case '20': return 'Fak Boy';
  66.            
  67.     }
  68. }
  69.     function makan(){
  70.         $nomor = $this->nomor;
  71.         switch($nomor) {
  72.             case '05': return 'Ramen';
  73.             case '06': return 'western';
  74.             case '07': return 'Fried Rice';
  75.             case '13': return 'Bread';
  76.             case '16': return 'Kecap';
  77.             case '20': return 'Chinese';
  78.        
  79.     }
  80. }
  81.      function berjalan(){
  82.         $nomor = $this->nomor;
  83.         switch($nomor) {
  84.             case '05': return 'Azka Show';
  85.             case '06': return 'Bama Show';
  86.             case '07': return 'Chandra Show';
  87.             case '13': return 'Fajar Show';
  88.             case '16': return 'Krisna Show';
  89.             case '20': return 'Muhammad Show';
  90.  
  91.         }
  92.     }
  93.  
  94.     function __construct($nama, $jenis_kelamin, $tanggal_lahir, $kebangsaan, $makanan, $nomor){
  95.         $this->nama = $nama;
  96.         $this->jenis_kelamin = $jenis_kelamin;
  97.         $this->tanggal_lahir = $tanggal_lahir;
  98.         $this->kebangsaan = $kebangsaan;
  99.         $this->makanan = $makanan;
  100.         $this->nomor = $nomor;
  101.     }
  102. }
  103. ?>
Add Comment
Please, Sign In to add comment