Files
kla-opp-schulzeug/12fi5/AEuP/Bank/example_bankv1.2.ps1
janik e054b82c6d .
2021-11-25 12:26:00 +01:00

126 lines
2.8 KiB
PowerShell
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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