<?php
class PersegiPanjang{
private $panjang;
private $lebar;
private $tinngi;
function persegiPanj(){
$this->panjang=0;
$this->lebar=0;
}
function hitungluas($panjang,$lebar){
return $this->panjang * $this->lebar;
}
function setPanjang($panjang){
$this->panjang;
}
function setLebar($lebar){
$this->lebar;
}
function getLuas(){
return hitungluas();//$this->setPanjang(11),$this->setLebar(9));
}
}
$object = new PersegiPanjang();
//$object->setLebar(10);
echo $object->setPanjang("jdhdjsds");
//echo "Luas : ".$object->getLuas();
?>
<?php
class mahasiswa {
var $nim;
var $nama;
function __construct($npm,$nama_lengkap){
$this->nim = $npm;
$this->nama= $nama_lengkap;
}
function tampilNim(){
echo "Hai, Nomor Induk Mahasiswa saya ".$this->nim."</br>";
}
function tampilNama(){
echo "Perkenalkan, nama saya ".$this->nama.". Senang bekenalan dengan Anda. :) ";
}
}
$riyanto = new mahasiswa ("0810031802221","Riyanto");
$riyanto->tampilNim();
$riyanto->tampilNama();
?>
0 Response to "class dasar php"
Posting Komentar