.
This commit is contained in:
@ -148,7 +148,7 @@ class cui {
|
|||||||
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: Überweisen"
|
||||||
Write-Host "6: Übersicht"
|
Write-Host "6: Übersicht"
|
||||||
Write-Host "0: Beenden"
|
Write-Host "0: Beenden"
|
||||||
$cmd = Read-Host "Aktion"
|
$cmd = Read-Host "Aktion"
|
||||||
|
|||||||
126
12fi5/AEuP/Bank/example_bankv1.2.ps1
Normal file
126
12fi5/AEuP/Bank/example_bankv1.2.ps1
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
cls
|
||||||
|
class konto {
|
||||||
|
|
||||||
|
[int]$nummer
|
||||||
|
[double]$stand
|
||||||
|
[kunde]$inhaber
|
||||||
|
static [string]$BIC = "BYLADEM1SWU"
|
||||||
|
[bool]$aktiv = $true
|
||||||
|
[double]$dispo = -1000
|
||||||
|
|
||||||
|
konto([int]$nummer){
|
||||||
|
$this.nummer = $nummer
|
||||||
|
}
|
||||||
|
|
||||||
|
konto([bool]$aktiv){
|
||||||
|
$this.aktiv
|
||||||
|
}
|
||||||
|
|
||||||
|
konto([int]$nummer,[double]$stand,[kunde]$inhaber){
|
||||||
|
$this.nummer = $nummer
|
||||||
|
$this.stand = $stand
|
||||||
|
$this.inhaber = $inhaber
|
||||||
|
}
|
||||||
|
|
||||||
|
konto([int]$nummer,[double]$stand,[string]$BIC){
|
||||||
|
$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 kunde{
|
||||||
|
|
||||||
|
[string]$vorname
|
||||||
|
[string]$nachname
|
||||||
|
[konto[]]$kontenliste = @()
|
||||||
|
|
||||||
|
kunde([string]$vorname,[string]$nachname){
|
||||||
|
$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 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){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
einzahlen([konto]$einzahlkonto,[double]$betrag){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
auszahlen([konto]$auszahlkonto,[double]$betrag){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
### Main ###
|
||||||
|
|
||||||
|
$bankverwaltung = [bankverwaltung]::new()
|
||||||
|
$bankverwaltung.kontoliste
|
||||||
|
""
|
||||||
|
$bankverwaltung.kontoliste[3].inhaber
|
||||||
Reference in New Issue
Block a user