Senin, 15 Desember 2014

CONTOH PHP SEDERHANA CLASS MANUSIA

<?php

class manusia{
//ini properti/atribut
private $Nama;
private $Nim;
private $Umur;
private $Alamat;
private $Profesi;
private $Mata;
private $Hidung;
private $Mulut;
private $Telinga;
private $Tangan;
private $Kaki;

//ini metode

function construct($Nama, $Nim, $Umur, $Alamat, $Profesi, $Mata, $Hidung, $Mulut, $Telinga, $Tangan, $Kaki){
$this->Nama=$Nama;
$this->Nim=$Nim;
$this->Umur=$Umur;
$this->Alamat=$Alamat;
$this->Profesi=$Profesi;
$this->Mata=$Mata;
$this->Hidung=$Hidung;
$this->Mulut=$Mulut;
$this->Telinga=$Telinga;
$this->Tangan=$Tangan;
$this->Kakir=$Kaki;

}

public function getNama(){
return $this->nama;
}
public function setNama($Nama){
return "Namaku : ". $this->nama=$Nama;
}
public function getNim(){
return $this->Nim;
}
public function setNim($Nim){
return "NIM : ". $this->nama=$Nim;
}
public function getUmur(){
return $this->umur;
}
public function setUmur($umur){
return "Umur : ".$this->umur=$umur;
}
public function getAlamat(){
return $this->alamat;
}
public function setalamat($Alamat){
return "Alamat : ".$this->Alamat=$Alamat;
}
public function getProfesi(){
return $this->Profesi;
}
public function setProfesi($Profesi){
return "Profesi : ".$this->Profesi=$Profesi;
}
public function getMata(){
return $this->Mata;
}
public function setMata($Mata){
return "Saya mempunyai mata : ".$this->Mata=$Mata;
}
public function getHidung(){
return $this->Hidung;
}
public function setHidung($Hidung){
return "Saya mempunyai Hidung : ".$this->Hidung=$Hidung;
}
public function getMulut(){
return $this->Mulut;
}
public function setMulut($Mulut){
return "Saya mempunyai Mulut : ".$this->Mulut=$Mulut;
}
public function getTelinga(){
return $this->Telinga;
}
public function setTelinga($Telinga){
return "Saya mempunyai Telinga : ".$this->Telinga=$Telinga;
}
public function getTangan(){
return $this->Tangan;
}
public function setTangan($Tangan){
return "Saya mempunyai Tangan : ".$this->Tangan=$Tangan;
}
public function getKaki(){
return $this->Kaki;
}
public function setKaki($Kaki){
return "Saya mempunyai Kaki : ".$this->Kaki=$Kaki;
}
}

$Yushinta=new manusia();
echo $Yushinta->setNama("Yushinta")."<br/>";
echo $Yushinta->setNim("130403010006")."<br/>";
echo $Yushinta->setUmur("20 th")."<br/>";
echo $Yushinta->setAlamat("Kepanjen")."<br/>";
echo $Yushinta->setProfesi("Pelajar")."<br/>";
echo $Yushinta->setMata("2")."<br/>";
echo $Yushinta->setHidung("1")."<br/>";
echo $Yushinta->setMulut("1")."<br/>";
echo $Yushinta->setTelinga("2")."<br/>";
echo $Yushinta->setTangan("2")."<br/>";
echo $Yushinta->setKaki("2")."<br/>";
?>

Tidak ada komentar:

Posting Komentar