kunde eunbau
parent
28f3210988
commit
8bd294616c
|
@ -7,26 +7,25 @@ import java.util.HashMap;
|
|||
public class Bank implements Serializable {
|
||||
private String name;
|
||||
private HashMap<Integer, Konto> konten = new HashMap<>();
|
||||
private HashMap<Integer, String> kunden = new HashMap<>();
|
||||
private HashMap<Integer, Kunde> kunden = new HashMap<>();
|
||||
|
||||
private int kontozähler;
|
||||
private int kontozähler;
|
||||
|
||||
|
||||
public Bank(String name) {
|
||||
this.name = name;
|
||||
this.kontozähler = -1;
|
||||
this.kontozähler = -1;
|
||||
}
|
||||
|
||||
public int addKonto(String vorname, String nachname, int alter, String wohnort, int auswahl) {
|
||||
Konto k;
|
||||
|
||||
if (auswahl == 1)
|
||||
k = new Konto(vorname, nachname, alter, wohnort, auswahl, ++kontozähler);
|
||||
k = new Konto(vorname, nachname, alter, ++kontozähler);
|
||||
else
|
||||
k = new Girokonto(vorname, nachname, alter, wohnort, auswahl, ++kontozähler);
|
||||
|
||||
k = new Girokonto(vorname, nachname, alter, ++kontozähler);
|
||||
addKunde(k, wohnort);
|
||||
konten.put(k.getKontonummer(), k);
|
||||
kunden.put(k.getKontonummer(), (vorname + " "+ nachname));
|
||||
|
||||
return k.getKontonummer();
|
||||
}
|
||||
|
@ -43,8 +42,14 @@ public class Bank implements Serializable {
|
|||
return konten.get(kontonummer);
|
||||
}
|
||||
|
||||
public Collection<String> getKundenliste() {
|
||||
public Collection<Kunde> getKundenliste() {
|
||||
return kunden.values();
|
||||
}
|
||||
|
||||
public void addKunde(Konto k, String wohnort) {
|
||||
Kunde ku = new Kunde(k, wohnort);
|
||||
kunden.put(k.getKontonummer(), ku);
|
||||
ku.addKontoZuKunde(k.getKontonummer());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ import java.io.Serializable;
|
|||
public class Depot extends Konto implements Serializable {
|
||||
|
||||
public Depot(String vorname, String nachname, int alter, String wohnort, int auswahl, int kontozähler) {
|
||||
super(vorname, nachname, alter, wohnort, auswahl, kontozähler);
|
||||
// TODO Auto-generated constructor stub
|
||||
super(vorname, nachname, alter, auswahl);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ import java.io.Serializable;
|
|||
public class Girokonto extends Konto implements Serializable {
|
||||
private long dispo = 100000;
|
||||
|
||||
public Girokonto(String vorname , String nachname, int alter, String wohnort, int auswahl, int kontozähler) {
|
||||
super(vorname, nachname, alter, wohnort, auswahl, kontozähler);
|
||||
public Girokonto(String vorname , String nachname, int alter, int auswahl) {
|
||||
super(vorname, nachname, alter, auswahl);
|
||||
}
|
||||
|
||||
public boolean überweise(Girokonto ziel, long betrag, String zweck) {
|
||||
|
|
|
@ -10,7 +10,7 @@ class GirokontoTest {
|
|||
|
||||
@Test
|
||||
void testÜberziehung() {
|
||||
Konto k = new Girokonto("Müller", null, 0, null, 0, 0);
|
||||
Konto k = new Girokonto("Müller", null, 0, 0);
|
||||
k.einzahlen(10000, "Test", "Einzahlung", "JUnit");
|
||||
|
||||
assertTrue(k.auszahlen(20000, "Test", "Einzahlung", "JUnit"));
|
||||
|
|
|
@ -7,15 +7,20 @@ public class Konto implements Serializable {
|
|||
private int nummer;
|
||||
protected long stand = 0;
|
||||
private String inhaber;
|
||||
private Kunde ku;
|
||||
private String vorname;
|
||||
private String nachname;
|
||||
private int alter;
|
||||
|
||||
protected ArrayList<Kontobewegung> kontobewegungen;
|
||||
|
||||
public Konto(String vorname, String nachname, int alter, String wohnort, int auswahl, int kontozähler) {
|
||||
public Konto(String vorname, String nachname, int alter, int kontozähler) {
|
||||
nummer = 1000 + kontozähler;
|
||||
this.inhaber = vorname+" "+nachname;
|
||||
this.vorname = vorname;
|
||||
this.nachname = nachname;
|
||||
this.alter = alter;
|
||||
|
||||
this.kontobewegungen = new ArrayList<>();
|
||||
this.ku = new Kunde(vorname, nachname, alter, wohnort, nummer);
|
||||
|
||||
}
|
||||
|
||||
|
@ -75,4 +80,19 @@ public class Konto implements Serializable {
|
|||
return saldo;
|
||||
}
|
||||
|
||||
public String getVorname() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getNachname() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getAlter() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ class KontoTest {
|
|||
|
||||
@Test
|
||||
void testKontoBasics() {
|
||||
Konto k = new Konto("Müller", null, 0, null, 0, 0);
|
||||
Konto k = new Konto("Müller", null, 0, 0);
|
||||
assertEquals("Müller", k.getInhaber());
|
||||
assertEquals(1000, k.getKontonummer());
|
||||
assertEquals(0, k.getKontostand());
|
||||
|
@ -16,12 +16,12 @@ class KontoTest {
|
|||
|
||||
@Test
|
||||
void testKontoEinUndAuszahlungUndSaldo() {
|
||||
Konto k = new Konto("Müller", null, 0, null, 0, 0);
|
||||
Konto k2 = new Konto("Mayer", null, 1, null, 0, 0);
|
||||
Konto k = new Konto("Müller", null, 0, 0);
|
||||
Konto k2 = new Konto("Mayer", null, 1, 0);
|
||||
testKontoEinUndAuszahlungUndSaldo(k, k2);
|
||||
|
||||
k = new Girokonto("Müller", null, 0, null, 0, 0);
|
||||
k2 = new Girokonto("Mayer", null, 1, null, 0, 0);
|
||||
k = new Girokonto("Müller", null, 0, 0);
|
||||
k2 = new Girokonto("Mayer", null, 1, 0);
|
||||
testKontoEinUndAuszahlungUndSaldo(k, k2);
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ class KontoTest {
|
|||
|
||||
@Test
|
||||
void testKeineÜberziehungFürSparkonten() {
|
||||
Konto k = new Konto("Müller", null, 0, null, 0, 0);
|
||||
Konto k = new Konto("Müller", null, 0, 0);
|
||||
k.einzahlen(100, "Test", "Einzahlung", "JUnit");
|
||||
assertFalse(k.auszahlen(500, "Test", "Auszahlung", "JUnit"));
|
||||
|
||||
|
|
|
@ -2,30 +2,46 @@ package de.hs_mannheim.informatik.bank.domain;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Kunde implements Serializable {
|
||||
private final String vorname;
|
||||
private String vorname;
|
||||
private String nachname;
|
||||
private int alter;
|
||||
private final int alter;
|
||||
private String wohnort;
|
||||
private int id;
|
||||
|
||||
private int kontonummer;
|
||||
private ArrayList<Integer> kAmount = new ArrayList<>();
|
||||
|
||||
public Kunde(String vorname, String nachname, int alter, String wohnort, int kontonummer) {
|
||||
this.vorname = vorname;
|
||||
this.nachname = nachname;
|
||||
this.alter = alter;
|
||||
|
||||
// public Kunde(String vorname, String nachname, int alter, String wohnort, int kontonummer) {
|
||||
// this.vorname = vorname;
|
||||
// this.nachname = nachname;
|
||||
// this.alter = alter;
|
||||
// this.wohnort = wohnort;
|
||||
// this.kontonummer = kontonummer;
|
||||
//
|
||||
// }
|
||||
public Kunde(Konto k, String Wohnort) {
|
||||
this.vorname = k.getVorname();
|
||||
this.nachname = k.getNachname();
|
||||
this.alter = k.getAlter();
|
||||
this.wohnort = wohnort;
|
||||
this.kontonummer = kontonummer;
|
||||
|
||||
}
|
||||
public String getFullName(String vorname, String nachname) {
|
||||
return vorname+" "+nachname;
|
||||
|
||||
|
||||
public void addKontoZuKunde(int kontonummer) {
|
||||
kAmount.add(kontonummer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Konto2 testlauf kunden " + kontonummer + " " + vorname +" "+ nachname + " "+ wohnort+ " ]";
|
||||
return "Kundendurchlauf " + id + " " + vorname +" "+ nachname + " "+ wohnort+ " und soviele konten"+kAmount+" ]";
|
||||
|
||||
}
|
||||
public ArrayList <Integer> getKontenamount() {
|
||||
return kAmount;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Collection;
|
|||
import de.hs_mannheim.informatik.bank.domain.Bank;
|
||||
import de.hs_mannheim.informatik.bank.domain.Girokonto;
|
||||
import de.hs_mannheim.informatik.bank.domain.Konto;
|
||||
import de.hs_mannheim.informatik.bank.domain.Kunde;
|
||||
import de.hs_mannheim.informatik.bank.infrastructure.Persistenz;
|
||||
|
||||
public class Banksystem {
|
||||
|
@ -19,7 +20,6 @@ public class Banksystem {
|
|||
|
||||
public int kontoAnlegen(String vorname, String nachname, int alter, String wohnort, int auswahl) throws Exception {
|
||||
int kontonummer = bank.addKonto(vorname, nachname, alter, wohnort, auswahl);
|
||||
|
||||
Persistenz.speichereBankDaten(this.bank, bank.getName());
|
||||
|
||||
return kontonummer;
|
||||
|
@ -41,11 +41,17 @@ public class Banksystem {
|
|||
return bank.getName();
|
||||
}
|
||||
|
||||
public long geldEinzahlen(int kontonummer, long betrag) throws Exception {
|
||||
public long geldEinzahlen(int kontonummer, long betrag) {
|
||||
Konto konto = bank.findeKonto(kontonummer);
|
||||
try {
|
||||
konto.einzahlen(betrag, "Einzahlung am Schalter", "Einzahlung", konto.getInhaber());
|
||||
|
||||
Persistenz.speichereBankDaten(this.bank, bank.getName());
|
||||
} catch (Exception e) {
|
||||
System.err.println("Einzahlung fehlgeschlagen");
|
||||
System.out.println("Einzahlung nicht registriert");
|
||||
|
||||
}
|
||||
|
||||
return konto.getKontostand();
|
||||
}
|
||||
|
@ -93,11 +99,11 @@ public class Banksystem {
|
|||
}
|
||||
|
||||
public String[] getKundenliste() {
|
||||
Collection<String> kunden = bank.getKundenliste();
|
||||
Collection<Kunde> kunden = bank.getKundenliste();
|
||||
String[] liste = new String[kunden.size()];
|
||||
|
||||
int i = 0;
|
||||
for (String k : kunden) {
|
||||
for (Kunde k : kunden) {
|
||||
liste[i++] = k.toString();
|
||||
}
|
||||
return liste;
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package de.hs_mannheim.informatik.bank.ui;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Scanner;
|
||||
|
||||
import de.hs_mannheim.informatik.bank.domain.Konto;
|
||||
import de.hs_mannheim.informatik.bank.facade.Banksystem;
|
||||
|
||||
public class UI {
|
||||
|
@ -20,7 +22,7 @@ public class UI {
|
|||
while (true) {
|
||||
System.out.println();
|
||||
System.out.println("--------");
|
||||
System.out.println("Hauptmenü");
|
||||
System.out.println("Hauptmenü");
|
||||
System.out.println("1 -> Konten anzeigen");
|
||||
System.out.println("2 -> Konto anlegen");
|
||||
System.out.println("3 -> Geld einzahlen");
|
||||
|
@ -40,9 +42,7 @@ public class UI {
|
|||
try {
|
||||
switch(input) {
|
||||
case 1: kontenAnzeigen(); break;
|
||||
case 2:
|
||||
kontoAnlegen();
|
||||
break;
|
||||
case 2: kontoAnlegen(); break;
|
||||
case 3: geldEinzahlen(); break;
|
||||
case 4: geldAuszahlen(); break;
|
||||
case 5: kontoauszugDrucken(); break;
|
||||
|
@ -107,7 +107,7 @@ public class UI {
|
|||
System.out.println("Konto mit der Nummer " + kontonummer + " neu angelegt.");
|
||||
}
|
||||
|
||||
private void geldEinzahlen() throws Exception {
|
||||
private void geldEinzahlen() {
|
||||
int kontonummer = 0;
|
||||
System.out.println("Geld einzahlen");
|
||||
System.out.println("Wie einzahlen? 1-> Kontonummer; 2-> Vorname Nachname");
|
||||
|
|
Loading…
Reference in New Issue