Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // buat abstract class
- abstract class komputer{
- // buat abstract method
- abstract protected function lihat_spec();
- }
- class laptop extends komputer{
- // implementasi abstract method
- protected function lihat_spec(){
- return "Lihat Spec Laptop...";
- }
- // method 'biasa'
- public function beli_laptop(){
- $a = $this->lihat_spec();
- return $a;
- }
- }
- // buat objek dari class laptop
- $laptop_baru = new laptop();
- echo $laptop_baru->lihat_spec();
- // Lihat Spec Laptop...
- echo "<br />";
- echo $laptop_baru->beli_laptop();
- // Beli Laptop...
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement