input checking

This commit is contained in:
janik
2021-10-21 12:31:41 +02:00
parent 15c2e13fda
commit e070913513

View File

@ -11,30 +11,36 @@ class konto {
}
[double]einzahlen([double]$menge) {
if ($menge -lt 0) {
throw "Einzahlungsmenge muss positiv sein!"
}
$this.guthaben += $menge
return $this.guthaben
}
[double]auszahlen([double]$menge) {
if ($menge -lt 0) {
throw "Auszahlungsmenge muss positiv sein!"
}
if (($this.guthaben - $menge) -gt (-1000)) {
$this.guthaben -= $menge
}
return $this.guthaben
}
[void]set_knr([int]$nr){ # public
[void]set_knr([int]$nr){
[string]$this.kontonr = $nr
}
[string]get_knr(){ # public
[string]get_knr(){
return $this.kontonr
}
[void]set_ktyp($typ){ # public
[void]set_ktyp($typ){
$this.ktyp = $typ
}
[string]get_ktyp(){ # public
[string]get_ktyp(){
return $this.ktyp
}
}