Advertisement
yoshoo

Untitled

Aug 25th, 2019
467
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.64 KB | None | 0 0
  1. <?php
  2.  
  3. class Produk {
  4.     public $judul = "judul",
  5.            $penulis = "penulis",
  6.            $penerbit = "penerbit",
  7.            $harga = 0;
  8.  
  9.     public function __construct($judul, $penulis, $penerbit, $harga) {
  10.         $this->judul = $judul;
  11.         $this->penulis = $penulis;
  12.         $this->penerbit = $penerbit;
  13.         $this->harga = $harga;
  14.     }
  15.  
  16.     public function getLabel() {
  17.         return "$this->penulis, $this->penerbit";
  18.     }
  19. }
  20.  
  21. $produk1 = new Produk("Naruto", "Masashi Kishimoto", "Shonen Jump", 30000);
  22. $produk2 = new Produk("Uncharted", "Neil Druckmann", "Sony Computer", 250000);
  23.  
  24.  
  25. echo "Komik : " . $produk1->getLabel();
  26. echo "<br>";
  27. echo "Game : " . $produk2->getLabel();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement