62 lines
1.5 KiB
PHP
62 lines
1.5 KiB
PHP
<?php
|
|
|
|
|
|
class Konto{
|
|
|
|
// Attribute
|
|
private string $iban;
|
|
private string $kontoInhaber;
|
|
private float $kontoStand;
|
|
private float $dispoRahmen;
|
|
|
|
// Kontruktor
|
|
public function __construct(string $cIban, string $cInhaber, float $cdispo) {
|
|
$this->iban = $cIban;
|
|
$this->kontoInhaber = $cInhaber;
|
|
$this->dispoRahmen = $cdispo;
|
|
$this->kontoStand = 0.0;
|
|
}
|
|
|
|
// SETTER
|
|
public function setDispoRahmen(float $sDispo){
|
|
$this->dispoRahmen = $sDispo;
|
|
}
|
|
|
|
// GETTER
|
|
public function getIban():string {
|
|
return $this->iban;
|
|
}
|
|
|
|
public function getKontoInhaber():string {
|
|
return $this->kontoInhaber;
|
|
}
|
|
|
|
public function getDispoRahmen():string {
|
|
return $this->dispoRahmen;
|
|
}
|
|
|
|
// Methoden
|
|
|
|
public function einzahlen(float $betrag){
|
|
$this->kontoStand += $betrag;
|
|
}
|
|
|
|
public function auszahlen(float $betrag) {
|
|
if ($betrag >= $this->kontoStand){
|
|
$this->kontoStand -= $betrag;
|
|
} else if ($betrag >= $this->dispoRahmen){
|
|
$this->dispoRahmen -= $betrag;
|
|
}
|
|
}
|
|
|
|
public function ausgeben(){
|
|
echo "<h1> Kontodaten: </h1>";
|
|
echo "<p><strong>IBAN:</strong> $this->iban</p>";
|
|
echo "<p><strong>Kontoinhaber:</strong> $this->kontoInhaber</p>";
|
|
echo "<p><strong>Disporahmen:</strong> $this->dispoRahmen</p>";
|
|
echo "<p><strong>Kontostand:</strong> $this->kontoStand</p>";
|
|
}
|
|
|
|
}
|
|
|
|
?>
|