.
This commit is contained in:
@ -94,11 +94,12 @@ class bank {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[void]übersicht() {
|
[void]übersicht() {
|
||||||
|
Write-Host "Übersicht"
|
||||||
foreach ($kunde in $this.kunden) {
|
foreach ($kunde in $this.kunden) {
|
||||||
Write-Host $kunde.name
|
Write-Host $kunde.name
|
||||||
foreach ($konto in $this.konten) {
|
foreach ($konto in $this.konten) {
|
||||||
if ($konto.kunde -eq $kunde) {
|
if ($konto.kunde -eq $kunde) {
|
||||||
Write-Host $konto.guthaben
|
Write-Host " " $konto.guthaben
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,6 +116,10 @@ class cui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[konto]select_konto([string]$use) {
|
[konto]select_konto([string]$use) {
|
||||||
|
if ($this.bank.konten.count -eq 0) {
|
||||||
|
Write-Host "Es sind keine Konten vorhanden!"
|
||||||
|
return $null
|
||||||
|
}
|
||||||
Write-Host "Wähle ein Konto" $use
|
Write-Host "Wähle ein Konto" $use
|
||||||
for ($i = 0; $i -lt $this.bank.konten.count; $i += 1) {
|
for ($i = 0; $i -lt $this.bank.konten.count; $i += 1) {
|
||||||
Write-Host "Konto" $i "("$this.bank.konten[$i].guthaben") von" $this.bank.konten[$i].kunde.name
|
Write-Host "Konto" $i "("$this.bank.konten[$i].guthaben") von" $this.bank.konten[$i].kunde.name
|
||||||
@ -122,31 +127,78 @@ class cui {
|
|||||||
return $this.bank.konten[$(Read-Host "Auswahl")]
|
return $this.bank.konten[$(Read-Host "Auswahl")]
|
||||||
}
|
}
|
||||||
|
|
||||||
run() {
|
[kunde]select_kunde([string]$use) {
|
||||||
$bname = Read-Host "Wähle einen Banknamen:"
|
if ($this.bank.kunden.count -eq 0) {
|
||||||
|
Write-Host "Es sind keine Kunden vorhanden!"
|
||||||
|
return $null
|
||||||
|
}
|
||||||
|
Write-Host "Wähle einen Kunden" $use
|
||||||
|
for ($i = 0; $i -lt $this.bank.kunden.count; $i += 1) {
|
||||||
|
Write-Host "Kunde" $i ":" $this.bank.kunden[$i].name
|
||||||
|
}
|
||||||
|
return $this.bank.kunden[$(Read-Host "Auswahl")]
|
||||||
|
}
|
||||||
|
|
||||||
|
[int]run() {
|
||||||
|
$bname = Read-Host "Wähle einen Banknamen"
|
||||||
$this.bank = [bank]::new($bname)
|
$this.bank = [bank]::new($bname)
|
||||||
while ($this.state -ne -1) {
|
while ($true) {
|
||||||
Write-Host "Wähle eine Aktion aus:"
|
Write-Host "Wähle eine Aktion aus:"
|
||||||
Write-Host "1: Kunde anlegen"
|
Write-Host "1: Kunde anlegen"
|
||||||
Write-Host "2: Konto anlegen"
|
Write-Host "2: Konto anlegen"
|
||||||
Write-Host "3: Einzahlen"
|
Write-Host "3: Einzahlen"
|
||||||
Write-Host "4: Auszahlen"
|
Write-Host "4: Auszahlen"
|
||||||
Write-Host "5: Überweißen"
|
Write-Host "5: Überweißen"
|
||||||
|
Write-Host "6: Übersicht"
|
||||||
Write-Host "0: Beenden"
|
Write-Host "0: Beenden"
|
||||||
|
$cmd = Read-Host "Aktion"
|
||||||
|
switch ($cmd) {
|
||||||
|
0 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
1 {
|
||||||
|
$this.bank.neukunde(
|
||||||
|
$(Read-Host "Vorname"),
|
||||||
|
$(Read-Host "Nachname")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
2 {
|
||||||
|
$k = $this.select_kunde("als Kontobesitzer")
|
||||||
|
if ($null -ne $k) {
|
||||||
|
$this.bank.konto_erstellen($k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
3 {
|
||||||
|
$k = $this.select_konto("für das Einzahlen")
|
||||||
|
if ($null -ne $k) {
|
||||||
|
$amount = Read-Host "Menge"
|
||||||
|
$this.bank.einzahlen($k, $amount)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
4 {
|
||||||
|
$k = $this.select_konto("für das Auszahlen")
|
||||||
|
if ($null -ne $k) {
|
||||||
|
$amount = Read-Host "Menge"
|
||||||
|
$this.bank.auszahlen($k, $amount)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
5 {
|
||||||
|
$von = $this.select_konto("als Quelle")
|
||||||
|
if ($null -ne $von) {
|
||||||
|
$nach = $this.select_konto("als Ziel")
|
||||||
|
$amount = Read-Host "Menge"
|
||||||
|
$this.bank.überweisen($von, $nach, $amount)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
6 {
|
||||||
|
$this.bank.übersicht()
|
||||||
|
Read-Host "Press any key"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return -1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#Tests
|
|
||||||
$bank = [bank]::new("Benannte Bank")
|
|
||||||
$kunde1 = $bank.neukunde("Kunde", "Kundengesicht")
|
|
||||||
$konto1 = $bank.konto_erstellen($kunde1)
|
|
||||||
$kunde2 = $bank.neukunde("Anderes", "Kundengesicht")
|
|
||||||
$konto2 = $bank.konto_erstellen($kunde2)
|
|
||||||
|
|
||||||
$bank.überweisen($konto1, $konto2, 150)
|
|
||||||
$bank.übersicht()
|
|
||||||
|
|
||||||
$cui = [cui]::new()
|
$cui = [cui]::new()
|
||||||
$cui.bank = $bank
|
$cui.run()
|
||||||
$cui.select_konto("Test")
|
|
||||||
Reference in New Issue
Block a user