overloaded constructors

This commit is contained in:
janik
2021-10-21 12:43:48 +02:00
parent e070913513
commit 7ac9e38d45

View File

@ -3,13 +3,26 @@ class konto {
[string]$ktyp [string]$ktyp
[string]$kunde [string]$kunde
[double]$guthaben [double]$guthaben
[string]$erstelldatum [datetime]$erstelldatum
konto() { konto() {
$this.guthaben = 0 $this.guthaben = 0
$this.erstelldatum = Get-Date $this.erstelldatum = Get-Date
} }
konto([string]knr) {
$this.guthaben = 0
$this.erstelldatum = Get-Date
$this.kontonr = knr
}
konto([string]knr, [string]ktyp) {
$this.guthaben = 0
$this.erstelldatum = Get-Date
$this.kontonr = knr
$this.ktyp = ktyp
}
[double]einzahlen([double]$menge) { [double]einzahlen([double]$menge) {
if ($menge -lt 0) { if ($menge -lt 0) {
throw "Einzahlungsmenge muss positiv sein!" throw "Einzahlungsmenge muss positiv sein!"