New: frames for different kontotypes and methods

gui
Caner Aliji 2022-12-04 14:10:36 +01:00
parent d384b5ceac
commit 1bbdf7aea5
9 changed files with 701 additions and 42 deletions

View File

@ -1,12 +1,8 @@
package de.hs_mannheim.informatik.bank; package de.hs_mannheim.informatik.bank;
import de.hs_mannheim.informatik.bank.facade.Banksystem; import de.hs_mannheim.informatik.bank.facade.Banksystem;
import de.hs_mannheim.informatik.bank.gui.AuswahlmenüSparkontoFrame;
import de.hs_mannheim.informatik.bank.gui.FehlerFrame;
import de.hs_mannheim.informatik.bank.gui.HauptmenüFrame; import de.hs_mannheim.informatik.bank.gui.HauptmenüFrame;
import de.hs_mannheim.informatik.bank.gui.KontoauszugFrame;
import de.hs_mannheim.informatik.bank.gui.LoginFrame;
import de.hs_mannheim.informatik.bank.gui.SaldoFrame;
public class Main { public class Main {
@ -14,11 +10,7 @@ public class Main {
Banksystem bs = new Banksystem("Spaßkasse Mannheim"); Banksystem bs = new Banksystem("Spaßkasse Mannheim");
//HauptmenüFrame hmf = new HauptmenüFrame(bs); HauptmenüFrame hmf = new HauptmenüFrame(bs);
//AuswahlmenüSparkontoFrame asf = new AuswahlmenüSparkontoFrame(bs);
SaldoFrame sf = new SaldoFrame(bs);
} }

View File

@ -0,0 +1,79 @@
package de.hs_mannheim.informatik.bank.gui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import de.hs_mannheim.informatik.bank.facade.Banksystem;
public class AktienAnzeigenFrame implements ActionListener {
private JPanel panel;
private JFrame frame;
private JButton button;
private JTextArea output;
private Banksystem bs;
public AktienAnzeigenFrame(Banksystem bs) {
this.bs = bs;
this.panel = new JPanel();
this.frame = new JFrame();
frame.setTitle(bs.getBankname() + " - Aktien anzeigen");
frame.setSize(500, 500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setResizable(false);
frame.add(panel);
panel.setLayout(null);
this.button = new JButton("Aktien anzeigen");
button.setBounds(10, 10, 100, 25);
button.addActionListener(this);
panel.add(button);
this.output = new JTextArea();
output.setBounds(10, 40, 470, 400);
output.setEditable(false);
panel.add(output);
frame.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("Aktien anzeigen...");
try {
String[] aktien = bs.getAktienliste();
if (aktien.length > 0) {
for (String s : aktien) {
output.append(s);
}
} else {
output.append("Keine Aktien vorhanden");
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}

View File

@ -0,0 +1,120 @@
package de.hs_mannheim.informatik.bank.gui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import de.hs_mannheim.informatik.bank.facade.Banksystem;
public class AktienKaufenFrame implements ActionListener{
private JPanel panel;
private JFrame frame;
private JLabel label;
private JLabel label2;
private JLabel label3;
private JLabel label4;
private JLabel label5;
private JLabel label6;
private JTextField input;
private JTextField input2;
private JTextField input3;
private JTextArea output;
private JButton button;
private Banksystem bs;
public AktienKaufenFrame(Banksystem bs) {
this.bs = bs;
this.panel = new JPanel();
this.frame = new JFrame();
frame.setTitle(bs.getBankname() + " - Aktien kaufen");
frame.setSize(500, 500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setResizable(false);
frame.add(panel);
panel.setLayout(null);
this.label = new JLabel("Folgende Aktien sind verfügbar:");
label.setBounds(10, 10, 200, 25);
panel.add(label);
this.label2 = new JLabel("1. Deutsche Bank (DBK.DE)");
label2.setBounds(10, 30, 200, 25);
panel.add(label2);
this.label3 = new JLabel("2. Deere & Company (DCO.DE)");
label3.setBounds(10, 50, 200, 25);
panel.add(label3);
this.label4 = new JLabel("Name d. Aktie");
label4.setBounds(10, 80, 200, 25);
panel.add(label4);
this.input = new JTextField(20);
input.setBounds(120, 80, 80, 20);
panel.add(input);
this.label5 = new JLabel("Anzahl");
label5.setBounds(10, 110, 200, 25);
panel.add(label5);
this.input2 = new JTextField(20);
input2.setBounds(120, 110, 80, 20);
panel.add(input2);
this.label6 = new JLabel("Kontonummer");
label6.setBounds(10, 140, 200, 25);
panel.add(label6);
this.input3 = new JTextField(20);
input3.setBounds(120, 140, 80, 20);
panel.add(input3);
this.button = new JButton("Kaufen");
button.setBounds(100, 200, 80, 25);
button.addActionListener(this);
panel.add(button);
this.output = new JTextArea();
output.setBounds(10, 250, 400, 200);
panel.add(output);
frame.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("Aktien kaufen...");
try {
output.append("Preise 1: " + bs.getAktienPreis("DBK.DE") + ", 2: " + bs.getAktienPreis("DCO.DE"));
String aktienName = input.getText();
int anzahl = Integer.parseInt(input2.getText());
int kontonummer = Integer.parseInt(input3.getText());
boolean erg = bs.aktienKauf(kontonummer, anzahl, aktienName);
output.append("Aktienkauf" + ((!erg)? " nicht" : "" ) + " erfolgreich. ");
} catch (Exception ex) {
ex.printStackTrace();
}
}
}

View File

@ -0,0 +1,146 @@
package de.hs_mannheim.informatik.bank.gui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import de.hs_mannheim.informatik.bank.facade.Banksystem;
public class AuswahlmenüDepotFrame implements ActionListener{
private JPanel panel;
private JFrame frame;
private JButton button;
private JButton button2;
private JButton button3;
private JButton button4;
private JButton button5;
private JButton button6;
private JButton button7;
private Banksystem bs;
public AuswahlmenüDepotFrame(Banksystem bs) {
this.bs = bs;
this.panel = new JPanel();
this.frame = new JFrame();
frame.setTitle(bs.getBankname() + " - Auswahlmenü Depot");
frame.setSize(400, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setResizable(false);
frame.add(panel);
panel.setLayout(null);
this.button = new JButton("Geld einzahlen");
button.setBounds(40, 50, 300, 25);
button.addActionListener(this);
panel.add(button);
this.button2 = new JButton("Geld abheben");
button2.setBounds(40, 80, 300, 25);
button2.addActionListener(this);
panel.add(button2);
this.button3 = new JButton("Kontoauszug");
button3.setBounds(40, 110, 300, 25);
button3.addActionListener(this);
panel.add(button3);
this.button4 = new JButton("Saldo");
button4.setBounds(40, 140, 300, 25);
button4.addActionListener(this);
panel.add(button4);
this.button5 = new JButton("Aktien kaufen");
button5.setBounds(40, 170, 300, 25);
button5.addActionListener(this);
panel.add(button5);
this.button6 = new JButton("Aktien anzeigen");
button6.setBounds(40, 200, 300, 25);
button6.addActionListener(this);
panel.add(button6);
this.button7 = new JButton("Hauptmenü");
button7.setBounds(40, 230, 300, 25);
button7.addActionListener(this);
panel.add(button7);
frame.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("Depot...");
if(e.getSource() == button) {
frame.dispose();
GeldEinzahlenFrame geldEinzahlenFrame = new GeldEinzahlenFrame(bs);
}
else if(e.getSource() == button2) {
frame.dispose();
GeldAuszahlenFrame geldAuszahlenFrame = new GeldAuszahlenFrame(bs);
}
else if(e.getSource() == button3) {
frame.dispose();
KontoauszugFrame kontoauszugFrame = new KontoauszugFrame(bs);
}
else if(e.getSource() == button4) {
frame.dispose();
SaldoFrame saldoFrame = new SaldoFrame(bs);
}
else if(e.getSource() == button5) {
frame.dispose();
AktienKaufenFrame aktienKaufenFrame = new AktienKaufenFrame(bs);
}
else if(e.getSource() == button6) {
frame.dispose();
AktienAnzeigenFrame aktienAnzeigenFrame = new AktienAnzeigenFrame(bs);
}
else if(e.getSource() == button7) {
frame.dispose();
HauptmenüFrame hauptmenüFrame = new HauptmenüFrame(bs);
}
else {
frame.dispose();
FehlerFrame fehlerFrame = new FehlerFrame(bs);
}
}
}

View File

@ -17,7 +17,6 @@ public class AuswahlmenüFrame implements ActionListener {
private JButton button2; private JButton button2;
private JButton button3; private JButton button3;
private JButton button4; private JButton button4;
private JButton button5;
private Banksystem bs; private Banksystem bs;
@ -46,21 +45,16 @@ public class AuswahlmenüFrame implements ActionListener {
button2.addActionListener(this); button2.addActionListener(this);
panel.add(button2); panel.add(button2);
this.button3 = new JButton("Geld einzahlen"); this.button3 = new JButton("Konto auswählen");
button3.setBounds(40, 110, 300, 25); button3.setBounds(40, 110, 300, 25);
button3.addActionListener(this); button3.addActionListener(this);
panel.add(button3); panel.add(button3);
this.button4 = new JButton("Geld abheben"); this.button4 = new JButton("Hauptmenü");
button4.setBounds(40, 140, 300, 25); button4.setBounds(40, 170, 300, 25);
button4.addActionListener(this); button4.addActionListener(this);
panel.add(button4); panel.add(button4);
this.button5 = new JButton("Hauptmenü");
button5.setBounds(40, 170, 300, 25);
button5.addActionListener(this);
panel.add(button5);
frame.setVisible(true); frame.setVisible(true);
} }
@ -83,19 +77,12 @@ public class AuswahlmenüFrame implements ActionListener {
} else if (e.getSource() == button3) { } else if (e.getSource() == button3) {
frame.dispose(); frame.dispose();
GeldEinzahlenFrame geldEinzahlenFrame = new GeldEinzahlenFrame(bs); KontoAuswahlFrame kontoAuswahlFrame = new KontoAuswahlFrame(bs);
} }
else if (e.getSource() == button4) { else if (e.getSource() == button4) {
frame.dispose();
GeldAuszahlenFrame geldAuszahlenFrame = new GeldAuszahlenFrame(bs);
}
else if (e.getSource() == button5) {
frame.dispose(); frame.dispose();
HauptmenüFrame hauptmenüFrame = new HauptmenüFrame(bs); HauptmenüFrame hauptmenüFrame = new HauptmenüFrame(bs);

View File

@ -0,0 +1,131 @@
package de.hs_mannheim.informatik.bank.gui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import de.hs_mannheim.informatik.bank.facade.Banksystem;
public class AuswahlmenüGirokontoFrame implements ActionListener {
private JPanel panel;
private JFrame frame;
private JButton button;
private JButton button2;
private JButton button3;
private JButton button4;
private JButton button5;
private JButton button6;
private Banksystem bs;
public AuswahlmenüGirokontoFrame(Banksystem bs) {
this.bs = bs;
this.panel = new JPanel();
this.frame = new JFrame();
frame.setTitle(bs.getBankname() + " - Auswahlmenü Girokonto");
frame.setSize(400, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setResizable(false);
frame.add(panel);
panel.setLayout(null);
this.button = new JButton("Geld einzahlen");
button.setBounds(40, 50, 300, 25);
button.addActionListener(this);
panel.add(button);
this.button2 = new JButton("Geld abheben");
button2.setBounds(40, 80, 300, 25);
button2.addActionListener(this);
panel.add(button2);
this.button3 = new JButton("Kontoauszug");
button3.setBounds(40, 110, 300, 25);
button3.addActionListener(this);
panel.add(button3);
this.button4 = new JButton("Saldo");
button4.setBounds(40, 140, 300, 25);
button4.addActionListener(this);
panel.add(button4);
this.button5 = new JButton("Überweisung");
button5.setBounds(40, 170, 300, 25);
button5.addActionListener(this);
panel.add(button5);
this.button6 = new JButton("Hauptmenü");
button6.setBounds(40, 200, 300, 25);
button6.addActionListener(this);
panel.add(button6);
frame.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("Girokonto...");
if(e.getSource() == button) {
frame.dispose();
GeldEinzahlenFrame geldEinzahlenFrame = new GeldEinzahlenFrame(bs);
}
else if(e.getSource() == button2) {
frame.dispose();
GeldAuszahlenFrame geldAuszahlenFrame = new GeldAuszahlenFrame(bs);
}
else if(e.getSource() == button3) {
frame.dispose();
KontoauszugFrame kontoauszugFrame = new KontoauszugFrame(bs);
}
else if(e.getSource() == button4) {
frame.dispose();
ÜberweisungsFrame überweisungsFrame = new ÜberweisungsFrame(bs);
}
else if(e.getSource() == button5) {
frame.dispose();
SaldoFrame saldoFrame = new SaldoFrame(bs);
}
else if(e.getSource() == button6) {
frame.dispose();
HauptmenüFrame hauptmenüFrame = new HauptmenüFrame(bs);
}
else {
frame.dispose();
FehlerFrame fehlerFrame = new FehlerFrame(bs);
}
}
}

View File

@ -0,0 +1,95 @@
package de.hs_mannheim.informatik.bank.gui;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import de.hs_mannheim.informatik.bank.domain.Kontoart;
import de.hs_mannheim.informatik.bank.facade.Banksystem;
public class KontoAuswahlFrame implements ActionListener{
private JPanel panel;
private JFrame frame;
private JButton button;
private JLabel label;
private JTextField input;
private Banksystem bs;
public KontoAuswahlFrame(Banksystem bs) {
this.bs = bs;
this.panel = new JPanel();
this.frame = new JFrame();
frame.setTitle(bs.getBankname() + " - Kontoauswahl");
frame.setSize(300, 200);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setResizable(false);
frame.add(panel);
panel.setLayout(null);
this.label = new JLabel("Kontonummer");
label.setBounds(10, 17, 80, 25);
panel.add(label);
this.input = new JTextField(20);
input.setBounds(120, 20, 80, 20);
panel.add(input);
this.button = new JButton("Login");
button.setBounds(100, 100, 80, 25);
button.addActionListener(this);
panel.add(button);
frame.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("Login...");
try {
if(bs.checkKontoart(Integer.parseInt(input.getText())) == Kontoart.Sparkonto) {
frame.dispose();
AuswahlmenüSparkontoFrame auswahlmenüSparkontoFrame = new AuswahlmenüSparkontoFrame(bs);
} else if(bs.checkKontoart(Integer.parseInt(input.getText())) == Kontoart.Girokonto) {
frame.dispose();
AuswahlmenüGirokontoFrame auswahlmenüGirokontoFrame = new AuswahlmenüGirokontoFrame(bs);
} else if(bs.checkKontoart(Integer.parseInt(input.getText())) == Kontoart.Depot) {
frame.dispose();
// TODO Auswahl Depot
} else {
frame.dispose();
FehlerFrame fehlerFrame = new FehlerFrame(bs);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}

View File

@ -19,8 +19,6 @@ public class LoginFrame implements ActionListener {
private JButton button; private JButton button;
private JTextField input; private JTextField input;
private JLabel label; private JLabel label;
private JTextField input2;
private JLabel label2;
private Banksystem bs; private Banksystem bs;
@ -47,14 +45,6 @@ public class LoginFrame implements ActionListener {
input.setBounds(120, 20, 80, 20); input.setBounds(120, 20, 80, 20);
panel.add(input); panel.add(input);
this.label2 = new JLabel("Kontonummer");
label2.setBounds(10, 47, 100, 25);
panel.add(label2);
this.input2 = new JTextField(20);
input2.setBounds(120, 50, 80, 20);
panel.add(input2);
this.button = new JButton("Login"); this.button = new JButton("Login");
button.setBounds(100, 100, 80, 25); button.setBounds(100, 100, 80, 25);
button.addActionListener(this); button.addActionListener(this);
@ -76,12 +66,8 @@ public class LoginFrame implements ActionListener {
if (bs.getCurrentKunde() != null) { if (bs.getCurrentKunde() != null) {
if(bs.checkKontoart(Integer.parseInt(input2.getText())).equals(Kontoart.Sparkonto)) {
frame.dispose(); frame.dispose();
AuswahlmenüSparkontoFrame amsf = new AuswahlmenüSparkontoFrame(bs); AuswahlmenüFrame amf = new AuswahlmenüFrame(bs);
}
} else { } else {

View File

@ -0,0 +1,123 @@
package de.hs_mannheim.informatik.bank.gui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import de.hs_mannheim.informatik.bank.facade.Banksystem;
public class ÜberweisungsFrame implements ActionListener{
private JPanel panel;
private JFrame frame;
private JLabel label;
private JLabel label2;
private JLabel label3;
private JLabel label4;
private JTextField input;
private JTextField input2;
private JTextField input3;
private JTextField input4;
private JTextArea output;
private JButton button;
private Banksystem bs;
public ÜberweisungsFrame(Banksystem bs) {
this.bs = bs;
this.panel = new JPanel();
this.frame = new JFrame();
frame.setTitle(bs.getBankname() + " - Überweisung");
frame.setSize(400, 400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setResizable(false);
frame.add(panel);
panel.setLayout(null);
this.label = new JLabel("Starkonto");
label.setBounds(40, 50, 80, 25);
panel.add(label);
this.input = new JTextField(20);
input.setBounds(120, 50, 165, 25);
panel.add(input);
this.label2 = new JLabel("Zielkonto");
label2.setBounds(40, 80, 80, 25);
panel.add(label2);
this.input2 = new JTextField(20);
input2.setBounds(120, 80, 165, 25);
panel.add(input2);
this.label3 = new JLabel("Betrag");
label3.setBounds(40, 110, 80, 25);
panel.add(label3);
this.input3 = new JTextField(20);
input3.setBounds(120, 110, 165, 25);
panel.add(input3);
this.label4 = new JLabel("Verwendungszweck");
label4.setBounds(40, 140, 80, 25);
panel.add(label4);
this.input4 = new JTextField(20);
input4.setBounds(120, 140, 165, 25);
panel.add(input4);
this.output = new JTextArea();
output.setBounds(40, 170, 300, 100);
output.setEditable(false);
panel.add(output);
this.button = new JButton("Überweisung durchführen");
button.setBounds(40, 280, 300, 25);
button.addActionListener(this);
panel.add(button);
frame.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("Überweisung durchführen...");
try {
int startkonto = Integer.parseInt(input.getText());
int zielkonto = Integer.parseInt(input2.getText());
double betrag = Double.parseDouble(input3.getText());
String verwendungszweck = input4.getText();
boolean erfolg = bs.überweisungBeauftragen(startkonto, zielkonto, (long) (betrag * 100), verwendungszweck);
output.append("Überweisung" + ((!erfolg) ? " nicht" : "") + " erfolgreich ausgeführt.");
input.setText("");
input2.setText("");
input3.setText("");
input4.setText("");
} catch (Exception ex) {
ex.printStackTrace();
}
}
}