Advertisement
setiyawanarif

index.php

Feb 24th, 2013
822
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.39 KB | None | 0 0
  1. <?php
  2. //this simple learning script php about class and inhiritance
  3.  
  4. include 'makhlukhidup.php';
  5. include 'hewan.php';
  6. include 'manusia.php';
  7. include 'tumbuhan.php';
  8.  
  9.  
  10. $hewan = new Hewan();
  11. $manusia= new Manusia();
  12. $tumbuhan= new Tumbuhan();
  13.  
  14.  
  15. //isi hewan
  16. $hewan->setNama("Kuda");
  17. //isi manusia
  18. $manusia->setNama("Paijo");
  19. //isi tumbuhan
  20. $tumbuhan->setNama("Bunga Matahari");
  21. ?>
  22. <div  align="center" style="border-bottom:2px solid #000; margin-top:20px; width:auto;">
  23. <?php
  24.  
  25. echo "".$hewan->bergerak($hewan->getNama())."&nbsp;public(method bergerak dari kelas induk makhluk hidup dilajlankan lewat kelas hewan)<br />";
  26. echo "".$manusia->bergerak($manusia->getNama())."&nbsp;public(method bergerak dari kelas induk Makhluk hidup dilajlankan lewat kelas manusia)<br />";
  27. echo "".$tumbuhan->bergerak($tumbuhan->getNama())."&nbsp;public(method bergerak dari kelas induk dilajlankan lewat kelas tumbuhan)<br />";
  28. ?>
  29. </div>
  30. <div align="center"  style="margin-top:20px;">
  31. <span > another method</span><br />
  32. <?php
  33. echo "".$hewan->makan($hewan->getNama())."&nbsp;public(method makan dari kelas induk makhluk hidup dilajlankan lewat kelas hewan)<br />";
  34. echo "".$manusia->makan($manusia->getNama())."&nbsp;public (method makan dari kelas induk Makhluk hidup dilajlankan lewat kelas manusia)<br />";
  35. echo  $manusia->runMakan($manusia->getNama())."this is protected from manusia";
  36. ?>
  37. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement