59 lines
1.2 KiB
PowerShell
59 lines
1.2 KiB
PowerShell
class konto {
|
|
[string]$kontonr
|
|
[string]$ktyp
|
|
[string]$kunde
|
|
[double]$guthaben
|
|
[datetime]$erstelldatum
|
|
|
|
konto() {
|
|
$this.guthaben = 0
|
|
$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) {
|
|
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){
|
|
[string]$this.kontonr = $nr
|
|
}
|
|
|
|
[string]get_knr(){
|
|
return $this.kontonr
|
|
}
|
|
|
|
[void]set_ktyp($typ){
|
|
$this.ktyp = $typ
|
|
}
|
|
|
|
[string]get_ktyp(){
|
|
return $this.ktyp
|
|
}
|
|
} |