Voll Upload SGD Fachinformatiker PHP
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
class Konto
|
||||
{
|
||||
private int $kontonummer;
|
||||
private float $kontostand;
|
||||
private string $inhaber;
|
||||
|
||||
public function __construct($kn = 000000, $ks = 000.00, $ki = "max, Mustermann")
|
||||
{
|
||||
$this->kontonummer = $kn;
|
||||
$this->kontostand = $ks;
|
||||
$this->inhaber = $ki;
|
||||
|
||||
echo "<p>Konto: " .$this->kontonummer ." wurde erfolgreich angelegt</p>";
|
||||
echo "<p>Kontoinhaber: " .$this->inhaber ."</p>";
|
||||
echo "<p>Kontostand: " .$this->kontostand ." Euro</p>";
|
||||
echo "<hr><br><hr>";
|
||||
}
|
||||
|
||||
public function einzahlung(float $wert)
|
||||
{
|
||||
$this->kontostand = $this->kontostand + $wert;
|
||||
|
||||
echo "<p>Der Betrag " .$wert ."€ wurde auf das Konto mit der Kontonummer " .$this->kontonummer ." eingezahlt. <br>";
|
||||
echo "Neuer Kontostand beträgt: " .$this->kontostand ."€</p>";
|
||||
echo "<hr><hr>";
|
||||
}
|
||||
|
||||
public function abheben(float $wert)
|
||||
{
|
||||
if ($this->kontostand - $wert >= 0)
|
||||
{
|
||||
$this->kontostand = $this->kontostand - $wert;
|
||||
echo "<p>Der Betrag " .$wert ."€ wurde vom Konto mit der Kontonummer " .$this->kontonummer ." ausgezahlt. <br>";
|
||||
echo "Neuer Kontostand beträgt: " .$this->kontostand ."€</p>";
|
||||
echo "<hr><hr>";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<p>Nicht genug Guthaben zum Auszahlen auf dem Konto " .$this->kontonummer ."</p>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user