172 lines
4.7 KiB
PowerShell
172 lines
4.7 KiB
PowerShell
cls
|
|
class konto {
|
|
|
|
[int]$nummer
|
|
[double]$stand
|
|
[kunde]$inhaber
|
|
static [string]$BIC = "BYLADEM1SWU"
|
|
[bool]$aktiv = $true
|
|
[double]$dispo = -1000
|
|
|
|
konto([int]$nummer){
|
|
if ($this.getType() -eq [konto]){
|
|
throw "Konto ist abstrakt"
|
|
}
|
|
$this.nummer = $nummer
|
|
}
|
|
|
|
konto([bool]$aktiv){
|
|
if ($this.getType() -eq [konto]){
|
|
throw "Konto ist abstrakt"
|
|
}
|
|
$this.aktiv
|
|
}
|
|
|
|
konto([int]$nummer,[double]$stand,[kunde]$inhaber){
|
|
if ($this.getType() -eq [konto]){
|
|
throw "Konto ist abstrakt"
|
|
}
|
|
$this.nummer = $nummer
|
|
$this.stand = $stand
|
|
$this.inhaber = $inhaber
|
|
}
|
|
|
|
konto([int]$nummer,[double]$stand,[string]$BIC){
|
|
if ($this.getType() -eq [konto]){
|
|
throw "Konto ist abstrakt"
|
|
}
|
|
$this.nummer = $nummer
|
|
$this.stand = $stand
|
|
$this.BIC = $BIC
|
|
}
|
|
|
|
[double]zeigeKontostand(){
|
|
return $this.stand
|
|
}
|
|
|
|
[void]einzahlen([double]$betrag){
|
|
$this.stand = $this.stand + $betrag
|
|
#write-host "Ihr neuer Kontostand beträgt" $this.stand "EUR"
|
|
}
|
|
|
|
[void]auszahlen([double]$betrag){
|
|
if($betrag -gt 0 ){
|
|
if(($this.stand - $betrag) -ge -1000){
|
|
$this.stand = $this.stand - $betrag
|
|
#write-host "Ihr neuer Kontostand beträgt" $this.stand "EUR"
|
|
}
|
|
else{
|
|
write-warning "Kreditlimit erreicht"
|
|
}
|
|
}
|
|
else{
|
|
write-warning "Ungültige Eingabe"
|
|
}
|
|
}
|
|
|
|
[void]überweisen([konto]$zielkonto,[double]$betrag){
|
|
$this.auszahlen($betrag)
|
|
$zielkonto.einzahlen($betrag)
|
|
}
|
|
|
|
[void]static statische_Methode(){
|
|
write-host "Ich bin eine statische Methode"
|
|
}
|
|
}
|
|
|
|
class girokonto : konto {
|
|
girokonto([int]$nummer) : base($nummer) {}
|
|
girokonto([bool]$aktiv) : base($aktiv) {}
|
|
girokonto([int]$nummer,[double]$stand,[kunde]$inhaber) : base($nummer, $stand, $inhaber) {}
|
|
girokonto([int]$nummer,[double]$stand,[string]$BIC) : base($nummer, $stand, $BIC) {}
|
|
}
|
|
|
|
class sparkonto : konto {
|
|
sparkonto([int]$nummer) : base($nummer) {}
|
|
sparkonto([bool]$aktiv) : base($aktiv) {}
|
|
sparkonto([int]$nummer,[double]$stand,[kunde]$inhaber) : base($nummer, $stand, $inhaber) {}
|
|
sparkonto([int]$nummer,[double]$stand,[string]$BIC) : base($nummer, $stand, $BIC) {}
|
|
}
|
|
|
|
class terminkonto : konto {
|
|
terminkonto([int]$nummer) : base($nummer) {}
|
|
terminkonto([bool]$aktiv) : base($aktiv) {}
|
|
terminkonto([int]$nummer,[double]$stand,[kunde]$inhaber) : base($nummer, $stand, $inhaber) {}
|
|
terminkonto([int]$nummer,[double]$stand,[string]$BIC) : base($nummer, $stand, $BIC) {}
|
|
}
|
|
|
|
class kreditkonto : konto {
|
|
kreditkonto([int]$nummer) : base($nummer) {}
|
|
kreditkonto([bool]$aktiv) : base($aktiv) {}
|
|
kreditkonto([int]$nummer,[double]$stand,[kunde]$inhaber) : base($nummer, $stand, $inhaber) {}
|
|
kreditkonto([int]$nummer,[double]$stand,[string]$BIC) : base($nummer, $stand, $BIC) {}
|
|
}
|
|
|
|
class kunde{
|
|
|
|
[string]$vorname
|
|
[string]$nachname
|
|
[konto[]]$kontenliste = @()
|
|
|
|
kunde([string]$vorname,[string]$nachname){
|
|
if ($this.getType() -eq [kunde]){
|
|
throw "Kunde ist abstrakt"
|
|
}
|
|
$this.vorname = $vorname
|
|
$this.nachname = $nachname
|
|
$this.erstelleKonto((read-Host "Anzahl Konten"))
|
|
}
|
|
|
|
erstelleKonto([int]$anzahl){
|
|
for($i = 0;$i -lt $anzahl;$i++){
|
|
$this.kontenliste += [konto]::new((read-host "Kontonummer"),0,$this)
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
class privatkunde : kunde {
|
|
privatkunde([string]$vorname,[string]$nachname) : base($vorname, $nachname) {}
|
|
}
|
|
|
|
class bankverwaltung{
|
|
|
|
$kundenliste = [System.Collections.ArrayList]::New()
|
|
$kontoliste = [System.Collections.ArrayList]::New()
|
|
|
|
bankverwaltung(){
|
|
for($i=0;$i -lt 3;$i++){
|
|
$temp = [kunde]::new((read-host "Kundenvorname"),(read-host "Kundennachname"))
|
|
$this.kundenliste.add($temp)
|
|
}
|
|
$this.ladeKontenInKontoliste()
|
|
}
|
|
|
|
ladeKontenInKontoliste(){
|
|
foreach($kunde in $this.kundenliste){
|
|
foreach($konto in $kunde.kontenliste){
|
|
$this.kontoliste.add($konto)
|
|
}
|
|
}
|
|
}
|
|
|
|
überweisen([konto]$quellkonto,[konto]$zielkonto,[double]$betrag){
|
|
$quellkonto.überweisen($zielkonto, $betrag)
|
|
}
|
|
|
|
einzahlen([konto]$einzahlkonto,[double]$betrag){
|
|
$einzahlkonto.einzahlen($betrag)
|
|
}
|
|
|
|
auszahlen([konto]$auszahlkonto,[double]$betrag){
|
|
$auszahlkonto.auszahlen($betrag)
|
|
}
|
|
}
|
|
|
|
### Main ###
|
|
|
|
$bankverwaltung = [bankverwaltung]::new()
|
|
$bankverwaltung.kontoliste
|
|
""
|
|
$bankverwaltung.kontoliste[3].inhaber |