forked from hummel/Bank-System
ActionListenerFehlen
parent
5820c0b754
commit
b33f0340f7
|
@ -2,12 +2,15 @@ package de.hs_mannheim.informatik.bank;
|
|||
|
||||
import de.hs_mannheim.informatik.bank.facade.Banksystem;
|
||||
import de.hs_mannheim.informatik.bank.ui.UI;
|
||||
import de.hs_mannheim.informatik.bank.ui.GUI;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Banksystem bs = new Banksystem("Spaßkasse Mannheim");
|
||||
GUI gui = new GUI(bs);
|
||||
UI ui = new UI(bs);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -42,7 +42,7 @@ public class Bank implements Serializable {
|
|||
}
|
||||
|
||||
public int addKunde(String vName, String nName, int alter, String wohnort, int kontonummer) {
|
||||
Kunde kunde = new Kunde(vName, nName, alter, wohnort, kontonummer, ++kundenzähler);
|
||||
Kunde kunde = new Kunde(vName, nName, alter, wohnort, konten.get(kontonummer), ++kundenzähler);
|
||||
return kunde.getKundennummer();
|
||||
}
|
||||
|
||||
|
|
|
@ -7,15 +7,17 @@ private String vName;
|
|||
private String nName;
|
||||
private int alter;
|
||||
private String wohnort;
|
||||
private int kundenNummer;
|
||||
private ArrayList<Konto> konten;
|
||||
|
||||
|
||||
public Kunde(String vName, String nName, int alter, String wohnort, Konto konto) {
|
||||
public Kunde(String vName, String nName, int alter, String wohnort, Konto konto, int kundenNummer) {
|
||||
this.vName = vName;
|
||||
this.nName = nName;
|
||||
this.alter = alter;
|
||||
this.wohnort = wohnort;
|
||||
this.konten.add(konto);
|
||||
this.kundenNummer = kundenNummer;
|
||||
}
|
||||
|
||||
|
||||
|
@ -29,6 +31,6 @@ public String toString() {
|
|||
|
||||
public int getKundennummer() {
|
||||
|
||||
return 0;
|
||||
return this.kundenNummer;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public class Banksystem {
|
|||
|
||||
public int kundeAnlegen(String vName, String nName, int alter, String wohnort, int kontonummer) {
|
||||
int kundennummer = bank.addKunde(vName, nName, alter, wohnort, kontonummer);
|
||||
return 0;
|
||||
return kundennummer;
|
||||
}
|
||||
|
||||
public int kontoAnlegen(String name, int auswahl) throws Exception {
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
package de.hs_mannheim.informatik.bank.ui;
|
||||
|
||||
import java.awt.Container;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import de.hs_mannheim.informatik.bank.facade.Banksystem;
|
||||
//import sun.util.resources.cldr.ext.CurrencyNames_en_RW;
|
||||
|
||||
public class GUI implements ActionListener {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Banksystem bs;
|
||||
private JTextField eingabe;
|
||||
private JTextArea ausgabe;
|
||||
private JButton ok;
|
||||
private JButton kontenAnzeigen;
|
||||
|
||||
public GUI(Banksystem bs) {
|
||||
JFrame jFrame = new JFrame(bs.getBankname());
|
||||
FlowLayout experimentLayout = new FlowLayout();
|
||||
|
||||
jFrame.setLayout(experimentLayout);
|
||||
this.bs = bs;
|
||||
/*this.setTitle(bs.getBankname());
|
||||
this.setSize(600, 600);
|
||||
this.setDefaultCloseOperation(GUI.EXIT_ON_CLOSE);*/
|
||||
jFrame.setSize(600, 600);
|
||||
|
||||
|
||||
JButton button1 = new JButton("Konten anzeigen");
|
||||
JButton button2 = new JButton("Konto anlegen");
|
||||
JButton button3 = new JButton("Geld einzahlen");
|
||||
JButton button4 = new JButton("Geld auszahlen");
|
||||
|
||||
jFrame.getContentPane().add(button1);
|
||||
jFrame.getContentPane().add(button2);
|
||||
jFrame.getContentPane().add(button3);
|
||||
jFrame.getContentPane().add(button4);
|
||||
|
||||
eingabe = new JTextField(20);
|
||||
|
||||
ausgabe = new JTextArea(5, 20);
|
||||
ausgabe.setLineWrap(true);
|
||||
ausgabe.setWrapStyleWord(true);
|
||||
|
||||
JScrollPane sp = new JScrollPane(ausgabe);
|
||||
|
||||
button1.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
UI.kontenAnzeigen(); // Hier bin Ich das letzte Mal
|
||||
}
|
||||
});
|
||||
|
||||
jFrame.setVisible(true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ausgabe.append(eingabe.getText() + System.getProperty("line.separator"));
|
||||
}
|
||||
|
||||
}
|
|
@ -31,6 +31,7 @@ public class UI {
|
|||
System.out.println("7 -> Saldo abfragen");
|
||||
|
||||
System.out.println("9 -> Beenden");
|
||||
System.out.println("10 -> GUI verwenden");
|
||||
System.out.println();
|
||||
|
||||
System.out.print("> ");
|
||||
|
@ -48,6 +49,7 @@ public class UI {
|
|||
case 6: überweisungBeauftragen(); break;
|
||||
case 7: saldoAbfragen(); break;
|
||||
case 9: break mainloop;
|
||||
case 10: guiAusführen(); break;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -60,7 +62,7 @@ public class UI {
|
|||
|
||||
} // hauptmenü
|
||||
|
||||
private int kundeAnlegen() throws Exception{
|
||||
private void kundeAnlegen() throws Exception{
|
||||
System.out.println("Bitte geben sie ihren Vornamen ein: ");
|
||||
String vName = sc.nextLine();
|
||||
|
||||
|
@ -80,7 +82,7 @@ public class UI {
|
|||
System.out.println("Kunde mit mit der Kundennummer " + kundennummer + "und mit der Kontonummer " + kontonummer + "neu angelegt");
|
||||
}
|
||||
|
||||
private void kontenAnzeigen() {
|
||||
void kontenAnzeigen() {
|
||||
String[] konten = bs.getKontenliste();
|
||||
if (konten.length > 0) {
|
||||
System.out.println("Folgende Konten sind aktuell verfügbar:");
|
||||
|
@ -187,5 +189,11 @@ public class UI {
|
|||
long saldo = bs.saldoBestimmen(konto, anzahl);
|
||||
System.out.printf("Der Saldo nach %d Kontobewegungen beträgt %.2f Euro.%n", anzahl, (saldo/100d));
|
||||
}
|
||||
|
||||
private void guiAusführen() {
|
||||
GUI gui = new GUI(bs);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue