New: aktien anzeigen
parent
44aacddf3e
commit
73914518bc
|
@ -15,7 +15,7 @@ public class Bank implements Serializable {
|
|||
|
||||
private HashMap<Integer, Konto> konten = new HashMap<>();
|
||||
private HashMap<Integer, Kunde> kundenMap = new HashMap<>();
|
||||
|
||||
private HashMap<Integer, String> aktienMap = new HashMap<>();
|
||||
|
||||
|
||||
public Bank(String name) {
|
||||
|
@ -49,6 +49,11 @@ public class Bank implements Serializable {
|
|||
return konten.get(kontonummer);
|
||||
}
|
||||
|
||||
public void addAktieToMap(int anzahl, String aktienName){
|
||||
aktienMap.put(anzahl, aktienName);
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
@ -57,6 +62,10 @@ public class Bank implements Serializable {
|
|||
return konten.values();
|
||||
}
|
||||
|
||||
public Collection<String> getAktienliste(){
|
||||
return aktienMap.values();
|
||||
}
|
||||
|
||||
public HashMap<Integer, Konto> getKonten() {
|
||||
return this.konten;
|
||||
}
|
||||
|
|
|
@ -27,13 +27,17 @@ public class Depot extends Konto{
|
|||
return false;
|
||||
}
|
||||
|
||||
public void addAktieToMap(int anzahl, String aktienName){
|
||||
aktienMap.put(anzahl, aktienName);
|
||||
}
|
||||
// public void addAktieToMap(int anzahl, String aktienName){
|
||||
// aktienMap.put(anzahl, aktienName);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Depot-" + super.toString();
|
||||
}
|
||||
|
||||
public HashMap<Integer, String> getAktienMap() {
|
||||
return aktienMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -72,6 +72,20 @@ public class Banksystem {
|
|||
|
||||
}
|
||||
|
||||
public String[] getAktienliste() {
|
||||
|
||||
Collection<String> aktien = bank.getAktienliste();
|
||||
String[] liste = new String[aktien.size()];
|
||||
|
||||
int i = 0;
|
||||
for (String aktie : aktien) {
|
||||
liste[i++] = aktie.toString();
|
||||
}
|
||||
|
||||
return liste;
|
||||
|
||||
}
|
||||
|
||||
public long geldEinzahlen(int kontonummer, long betrag) throws IOException {
|
||||
Konto konto = bank.findeKonto(kontonummer);
|
||||
konto.einzahlen(betrag, "Einzahlung am Schalter", "Einzahlung", konto.getKunde().getName());
|
||||
|
|
|
@ -82,6 +82,7 @@ public class TUI {
|
|||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("Kunde mit der ID " + bs.getKundenID() + " wurde erstellt.");
|
||||
}
|
||||
|
||||
|
||||
|
@ -138,6 +139,22 @@ public class TUI {
|
|||
}
|
||||
|
||||
|
||||
private void aktienAnzeigen(){
|
||||
|
||||
String[] aktien = bs.getAktienliste();
|
||||
|
||||
if (aktien.length > 0) {
|
||||
System.out.println("Folgende Aktien sind aktuell verfügbar:");
|
||||
for (String s : aktien) {
|
||||
System.out.println(s);
|
||||
}
|
||||
} else {
|
||||
System.out.println("Bisher keine Aktien gekauft.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void kontoAuswählen(){
|
||||
|
||||
boolean running = true;
|
||||
|
@ -270,7 +287,8 @@ public class TUI {
|
|||
System.out.println("3 -> Überweisung beauftragen");
|
||||
System.out.println("4 -> Saldo abfragen");
|
||||
System.out.println("5 -> Aktien kaufen");
|
||||
System.out.println("6 -> Zurück zum Hauptmenü");
|
||||
System.out.println("6 -> Aktien anzeigen");
|
||||
System.out.println("7 -> Zurück zum Hauptmenü");
|
||||
System.out.println();
|
||||
|
||||
System.out.print("> ");
|
||||
|
@ -298,6 +316,9 @@ public class TUI {
|
|||
aktienKaufen();
|
||||
break;
|
||||
case 6:
|
||||
aktienAnzeigen();
|
||||
break;
|
||||
case 7:
|
||||
running = false;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue