add: files from last time and task
This commit is contained in:
60
Zweites Jahr/uebung_konto/konto.class.php
Normal file
60
Zweites Jahr/uebung_konto/konto.class.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Konto{
|
||||
|
||||
private string $iban;
|
||||
private string $kontoInhaber;
|
||||
private float $kontoStand;
|
||||
private float $dispoRahmen;
|
||||
|
||||
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>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user