forked from hummel/Bank-System
Compare commits
No commits in common. "main" and "main" have entirely different histories.
|
@ -1,7 +1,11 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="module" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -2,15 +2,12 @@ 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.ui.UI;
|
import de.hs_mannheim.informatik.bank.ui.UI;
|
||||||
import de.hs_mannheim.informatik.bank.ui.GUI;
|
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
Banksystem bs = new Banksystem("Spaßkasse Mannheim");
|
Banksystem bs = new Banksystem("Spaßkasse Mannheim");
|
||||||
GUI gui = new GUI(bs);
|
|
||||||
UI ui = new UI(bs);
|
UI ui = new UI(bs);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -7,9 +7,7 @@ import java.util.HashMap;
|
||||||
public class Bank implements Serializable {
|
public class Bank implements Serializable {
|
||||||
private String name;
|
private String name;
|
||||||
private HashMap<Integer, Konto> konten = new HashMap<>();
|
private HashMap<Integer, Konto> konten = new HashMap<>();
|
||||||
private HashMap<Integer, Kunde> kunden = new HashMap<>();
|
|
||||||
private int kontozähler;
|
private int kontozähler;
|
||||||
private int kundenzähler;
|
|
||||||
|
|
||||||
public Bank(String name) {
|
public Bank(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@ -41,9 +39,4 @@ public class Bank implements Serializable {
|
||||||
return konten.get(kontonummer);
|
return konten.get(kontonummer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int addKunde(String vName, String nName, int alter, String wohnort, int kontonummer) {
|
|
||||||
Kunde kunde = new Kunde(vName, nName, alter, wohnort, konten.get(kontonummer), ++kundenzähler);
|
|
||||||
return kunde.getKundennummer();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
package de.hs_mannheim.informatik.bank.domain;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
public class Kunde implements Serializable{
|
|
||||||
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, int kundenNummer) {
|
|
||||||
this.vName = vName;
|
|
||||||
this.nName = nName;
|
|
||||||
this.alter = alter;
|
|
||||||
this.wohnort = wohnort;
|
|
||||||
this.konten.add(konto);
|
|
||||||
this.kundenNummer = kundenNummer;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return this.vName + ";" + this.nName + ";" + this.alter + ";" + this.wohnort + ";";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public int getKundennummer() {
|
|
||||||
|
|
||||||
return this.kundenNummer;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -17,11 +17,6 @@ public class Banksystem {
|
||||||
this.bank = new Bank(bankname);
|
this.bank = new Bank(bankname);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int kundeAnlegen(String vName, String nName, int alter, String wohnort, int kontonummer) {
|
|
||||||
int kundennummer = bank.addKunde(vName, nName, alter, wohnort, kontonummer);
|
|
||||||
return kundennummer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int kontoAnlegen(String name, int auswahl) throws Exception {
|
public int kontoAnlegen(String name, int auswahl) throws Exception {
|
||||||
int kontonummer = bank.addKonto(name, auswahl);
|
int kontonummer = bank.addKonto(name, auswahl);
|
||||||
|
|
||||||
|
@ -97,10 +92,4 @@ public class Banksystem {
|
||||||
return konto.berechneSaldo(anzahl);
|
return konto.berechneSaldo(anzahl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void systemwiederherstellung() throws ClassNotFoundException, Exception{
|
|
||||||
this.bank = (Bank) Persistenz.ladeBankDaten(bank.getName());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,6 @@ import java.io.FileOutputStream;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
|
|
||||||
import jdk.internal.misc.FileSystemOption;
|
|
||||||
|
|
||||||
public class Persistenz {
|
public class Persistenz {
|
||||||
private static final String BANK_DATEI = "-bank-data.ser";
|
private static final String BANK_DATEI = "-bank-data.ser";
|
||||||
|
|
||||||
|
@ -16,16 +14,12 @@ public class Persistenz {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void speichereBankDaten(Object bank, String name) throws Exception {
|
public static void speichereBankDaten(Object bank, String name) throws Exception {
|
||||||
|
|
||||||
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(name + BANK_DATEI));
|
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(name + BANK_DATEI));
|
||||||
oos.writeObject(bank);
|
oos.writeObject(bank);
|
||||||
oos.close();
|
oos.close();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object ladeBankDaten(String name) throws Exception, ClassNotFoundException {
|
public static Object ladeBankDaten(String name) throws Exception {
|
||||||
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(name + BANK_DATEI));
|
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(name + BANK_DATEI));
|
||||||
Object bank = ois.readObject();
|
Object bank = ois.readObject();
|
||||||
ois.close();
|
ois.close();
|
||||||
|
|
|
@ -1,78 +0,0 @@
|
||||||
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"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -21,7 +21,6 @@ public class UI {
|
||||||
System.out.println();
|
System.out.println();
|
||||||
System.out.println("--------");
|
System.out.println("--------");
|
||||||
System.out.println("Hauptmenü");
|
System.out.println("Hauptmenü");
|
||||||
System.out.println("0 -> Kunden Account anlegen");
|
|
||||||
System.out.println("1 -> Konten anzeigen");
|
System.out.println("1 -> Konten anzeigen");
|
||||||
System.out.println("2 -> Konto anlegen");
|
System.out.println("2 -> Konto anlegen");
|
||||||
System.out.println("3 -> Geld einzahlen");
|
System.out.println("3 -> Geld einzahlen");
|
||||||
|
@ -31,7 +30,6 @@ public class UI {
|
||||||
System.out.println("7 -> Saldo abfragen");
|
System.out.println("7 -> Saldo abfragen");
|
||||||
|
|
||||||
System.out.println("9 -> Beenden");
|
System.out.println("9 -> Beenden");
|
||||||
System.out.println("10 -> GUI verwenden");
|
|
||||||
System.out.println();
|
System.out.println();
|
||||||
|
|
||||||
System.out.print("> ");
|
System.out.print("> ");
|
||||||
|
@ -40,16 +38,16 @@ public class UI {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
switch(input) {
|
switch(input) {
|
||||||
case 0: kundeAnlegen(); break;
|
|
||||||
case 1: kontenAnzeigen(); break;
|
case 1: kontenAnzeigen(); break;
|
||||||
case 2: kontoAnlegen();break;
|
case 2:
|
||||||
|
kontoAnlegen();
|
||||||
|
break;
|
||||||
case 3: geldEinzahlen(); break;
|
case 3: geldEinzahlen(); break;
|
||||||
case 4: geldAuszahlen(); break;
|
case 4: geldAuszahlen(); break;
|
||||||
case 5: kontoauszugDrucken(); break;
|
case 5: kontoauszugDrucken(); break;
|
||||||
case 6: überweisungBeauftragen(); break;
|
case 6: überweisungBeauftragen(); break;
|
||||||
case 7: saldoAbfragen(); break;
|
case 7: saldoAbfragen(); break;
|
||||||
case 9: break mainloop;
|
case 9: break mainloop;
|
||||||
case 10: guiAusführen(); break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -62,27 +60,7 @@ public class UI {
|
||||||
|
|
||||||
} // hauptmenü
|
} // hauptmenü
|
||||||
|
|
||||||
private void kundeAnlegen() throws Exception{
|
private void kontenAnzeigen() {
|
||||||
System.out.println("Bitte geben sie ihren Vornamen ein: ");
|
|
||||||
String vName = sc.nextLine();
|
|
||||||
|
|
||||||
System.out.println("Bitte geben sie ihren Nachnamen ein: ");
|
|
||||||
String nName = sc.nextLine();
|
|
||||||
|
|
||||||
System.out.println("Bitte geben sie ihr Alter ein: ");
|
|
||||||
int alter = Integer.parseInt(sc.nextLine());
|
|
||||||
|
|
||||||
System.out.println("Bitte geben sie ihren Wohnort ein: ");
|
|
||||||
String wohnort = sc.nextLine();
|
|
||||||
|
|
||||||
System.out.println("Möchten Sie ein Sparkonto (1) oder ein Girokonto (2) anlegen?");
|
|
||||||
int auswahl = Integer.parseInt(sc.nextLine());
|
|
||||||
int kontonummer = bs.kontoAnlegen(vName+nName, auswahl);
|
|
||||||
int kundennummer = bs.kundeAnlegen(vName, nName, alter, wohnort, kontonummer);
|
|
||||||
System.out.println("Kunde mit mit der Kundennummer " + kundennummer + "und mit der Kontonummer " + kontonummer + "neu angelegt");
|
|
||||||
}
|
|
||||||
|
|
||||||
void kontenAnzeigen() {
|
|
||||||
String[] konten = bs.getKontenliste();
|
String[] konten = bs.getKontenliste();
|
||||||
if (konten.length > 0) {
|
if (konten.length > 0) {
|
||||||
System.out.println("Folgende Konten sind aktuell verfügbar:");
|
System.out.println("Folgende Konten sind aktuell verfügbar:");
|
||||||
|
@ -105,7 +83,7 @@ public class UI {
|
||||||
System.out.println("Konto mit der Nummer " + kontonummer + " neu angelegt.");
|
System.out.println("Konto mit der Nummer " + kontonummer + " neu angelegt.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void geldEinzahlen() {
|
private void geldEinzahlen() throws Exception {
|
||||||
System.out.println("Geld einzahlen");
|
System.out.println("Geld einzahlen");
|
||||||
System.out.print("Bitte die gewünschte Kontonummer eingeben: ");
|
System.out.print("Bitte die gewünschte Kontonummer eingeben: ");
|
||||||
int kontonummer = Integer.parseInt(sc.nextLine());
|
int kontonummer = Integer.parseInt(sc.nextLine());
|
||||||
|
@ -114,23 +92,12 @@ public class UI {
|
||||||
|
|
||||||
System.out.print("Bitte den gewünschten Betrag eingeben: ");
|
System.out.print("Bitte den gewünschten Betrag eingeben: ");
|
||||||
double betrag = Double.parseDouble(sc.nextLine());
|
double betrag = Double.parseDouble(sc.nextLine());
|
||||||
try {
|
|
||||||
long neuerKontostand = bs.geldEinzahlen(kontonummer, (long)betrag * 100);
|
long neuerKontostand = bs.geldEinzahlen(kontonummer, (long)betrag * 100);
|
||||||
|
|
||||||
System.out.printf("Einzahlung erfolgreich, neuer Kontostand = %.2f Euro", (neuerKontostand / 100.0));
|
System.out.printf("Einzahlung erfolgreich, neuer Kontostand = %.2f Euro", (neuerKontostand / 100.0));
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
System.err.println("Einzahlung nicht erfolgreich, wurde nicht gespeichert");
|
|
||||||
try {
|
|
||||||
bs.systemwiederherstellung();
|
|
||||||
}
|
|
||||||
catch (Exception cnfe) {
|
|
||||||
System.err.println("Fehler aufgetreten(ClassNotFoundException)");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void geldAuszahlen() throws Exception {
|
private void geldAuszahlen() throws Exception {
|
||||||
System.out.println("Geld auszahlen");
|
System.out.println("Geld auszahlen");
|
||||||
System.out.print("Bitte die gewünschte Kontonummer eingeben: ");
|
System.out.print("Bitte die gewünschte Kontonummer eingeben: ");
|
||||||
|
@ -190,10 +157,4 @@ public class UI {
|
||||||
System.out.printf("Der Saldo nach %d Kontobewegungen beträgt %.2f Euro.%n", anzahl, (saldo/100d));
|
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