Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Produk {
- public $judul,
- $penulis,
- $penerbit,
- $harga;
- public function __construct($judul = "judul", $penulis = "penulis", $penerbit = "penerbit", $harga = "0") {
- $this->judul = $judul;
- $this->penulis = $penulis;
- $this->penerbit = $penerbit;
- $this->harga = $harga;
- }
- public function getLabel() {
- return "$this->penulis, $this->penerbit";
- }
- }
- $produk1 = new Produk("Naruto", "Masashi Kishimoto", "Shonen Jump", 30000);
- $produk2 = new Produk("Uncharted", "Neil Druckmann", "Sony Computer", 250000);
- $produk3 = new Produk("Dragon Ball");
- echo "Komik : " . $produk1->getLabel();
- echo "<br>";
- echo "Game : " . $produk2->getLabel();
- echo "<br>";
- var_dump($produk3);
- echo "<br>";
- echo "Barang : " . $produk3->getLabel();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement