forked from hummel/Bank-System
hinzufügen der Girokontoklasse und der Überweißen Methode
parent
301e12ade5
commit
383d627558
|
@ -921,7 +921,7 @@
|
||||||
<FreeLineShapes />
|
<FreeLineShapes />
|
||||||
<ConnectedShapes>
|
<ConnectedShapes>
|
||||||
<ConnectedShapesRecord>
|
<ConnectedShapesRecord>
|
||||||
<ObjectID>810c924b577246088ff7a60dda51425b</ObjectID>
|
<ObjectID>0a3c5d25617741b49364bce3f0477dba</ObjectID>
|
||||||
<ParentShapeId>5d0581b78aed4ee8b0bf6527c2681a23</ParentShapeId>
|
<ParentShapeId>5d0581b78aed4ee8b0bf6527c2681a23</ParentShapeId>
|
||||||
<ChildShapeId>4e970de88c214cf0b3635042b9e226fb</ChildShapeId>
|
<ChildShapeId>4e970de88c214cf0b3635042b9e226fb</ChildShapeId>
|
||||||
<Text />
|
<Text />
|
||||||
|
@ -988,7 +988,7 @@
|
||||||
<LineStrokeThickness>1</LineStrokeThickness>
|
<LineStrokeThickness>1</LineStrokeThickness>
|
||||||
</ConnectedShapesRecord>
|
</ConnectedShapesRecord>
|
||||||
<ConnectedShapesRecord>
|
<ConnectedShapesRecord>
|
||||||
<ObjectID>c56a5392fdcb4cb99bde4b0b7aca7069</ObjectID>
|
<ObjectID>d20223511e3946608b3e194faf04afdc</ObjectID>
|
||||||
<ParentShapeId>4e970de88c214cf0b3635042b9e226fb</ParentShapeId>
|
<ParentShapeId>4e970de88c214cf0b3635042b9e226fb</ParentShapeId>
|
||||||
<ChildShapeId>1c6ab24e7855452dbfd83e71bee81fdf</ChildShapeId>
|
<ChildShapeId>1c6ab24e7855452dbfd83e71bee81fdf</ChildShapeId>
|
||||||
<Text />
|
<Text />
|
||||||
|
@ -1055,7 +1055,7 @@
|
||||||
<LineStrokeThickness>1</LineStrokeThickness>
|
<LineStrokeThickness>1</LineStrokeThickness>
|
||||||
</ConnectedShapesRecord>
|
</ConnectedShapesRecord>
|
||||||
<ConnectedShapesRecord>
|
<ConnectedShapesRecord>
|
||||||
<ObjectID>a5e37ca5b6574a1ba47d13b50483c249</ObjectID>
|
<ObjectID>7f19a4c81d424603bb6ffebd4ded84b8</ObjectID>
|
||||||
<ParentShapeId>1c6ab24e7855452dbfd83e71bee81fdf</ParentShapeId>
|
<ParentShapeId>1c6ab24e7855452dbfd83e71bee81fdf</ParentShapeId>
|
||||||
<ChildShapeId>a32ed2170b0d45968a4723b3a4f7e540</ChildShapeId>
|
<ChildShapeId>a32ed2170b0d45968a4723b3a4f7e540</ChildShapeId>
|
||||||
<Text />
|
<Text />
|
||||||
|
@ -1122,7 +1122,7 @@
|
||||||
<LineStrokeThickness>1</LineStrokeThickness>
|
<LineStrokeThickness>1</LineStrokeThickness>
|
||||||
</ConnectedShapesRecord>
|
</ConnectedShapesRecord>
|
||||||
<ConnectedShapesRecord>
|
<ConnectedShapesRecord>
|
||||||
<ObjectID>7a5dc86d6db2441cad85c4f6836ea3ff</ObjectID>
|
<ObjectID>96fed068f6864da9b7d5f5efa7671109</ObjectID>
|
||||||
<ParentShapeId>607ea9ee4a994d45bafe757014698907</ParentShapeId>
|
<ParentShapeId>607ea9ee4a994d45bafe757014698907</ParentShapeId>
|
||||||
<ChildShapeId>b49af04e608549c89ac919c9d3e57c01</ChildShapeId>
|
<ChildShapeId>b49af04e608549c89ac919c9d3e57c01</ChildShapeId>
|
||||||
<Text />
|
<Text />
|
||||||
|
@ -1189,7 +1189,7 @@
|
||||||
<LineStrokeThickness>1</LineStrokeThickness>
|
<LineStrokeThickness>1</LineStrokeThickness>
|
||||||
</ConnectedShapesRecord>
|
</ConnectedShapesRecord>
|
||||||
<ConnectedShapesRecord>
|
<ConnectedShapesRecord>
|
||||||
<ObjectID>edf473f522ab4420b4518d563f340bbf</ObjectID>
|
<ObjectID>74108319092343229dde6ae748303cea</ObjectID>
|
||||||
<ParentShapeId>a838e00032384ba2ab7988a1b0c7240e</ParentShapeId>
|
<ParentShapeId>a838e00032384ba2ab7988a1b0c7240e</ParentShapeId>
|
||||||
<ChildShapeId>6ef27b03d235471db3d6ff4e8d96a5f2</ChildShapeId>
|
<ChildShapeId>6ef27b03d235471db3d6ff4e8d96a5f2</ChildShapeId>
|
||||||
<Text>Daten der aktion</Text>
|
<Text>Daten der aktion</Text>
|
||||||
|
@ -1256,7 +1256,7 @@
|
||||||
<LineStrokeThickness>1</LineStrokeThickness>
|
<LineStrokeThickness>1</LineStrokeThickness>
|
||||||
</ConnectedShapesRecord>
|
</ConnectedShapesRecord>
|
||||||
<ConnectedShapesRecord>
|
<ConnectedShapesRecord>
|
||||||
<ObjectID>e576b55981274419bf009ad25e69cbb1</ObjectID>
|
<ObjectID>1c87411297f44403b5374fe7d2264b2f</ObjectID>
|
||||||
<ParentShapeId>6ef27b03d235471db3d6ff4e8d96a5f2</ParentShapeId>
|
<ParentShapeId>6ef27b03d235471db3d6ff4e8d96a5f2</ParentShapeId>
|
||||||
<ChildShapeId>37eedc119a2c4e998b2254b25f4e7f87</ChildShapeId>
|
<ChildShapeId>37eedc119a2c4e998b2254b25f4e7f87</ChildShapeId>
|
||||||
<Text>Abheben</Text>
|
<Text>Abheben</Text>
|
||||||
|
@ -1323,7 +1323,7 @@
|
||||||
<LineStrokeThickness>1</LineStrokeThickness>
|
<LineStrokeThickness>1</LineStrokeThickness>
|
||||||
</ConnectedShapesRecord>
|
</ConnectedShapesRecord>
|
||||||
<ConnectedShapesRecord>
|
<ConnectedShapesRecord>
|
||||||
<ObjectID>80fab382ef394d209427522726f56358</ObjectID>
|
<ObjectID>1fcdc0d0e08244338a11ae5d57be124e</ObjectID>
|
||||||
<ParentShapeId>6ef27b03d235471db3d6ff4e8d96a5f2</ParentShapeId>
|
<ParentShapeId>6ef27b03d235471db3d6ff4e8d96a5f2</ParentShapeId>
|
||||||
<ChildShapeId>37eedc119a2c4e998b2254b25f4e7f87</ChildShapeId>
|
<ChildShapeId>37eedc119a2c4e998b2254b25f4e7f87</ChildShapeId>
|
||||||
<Text>Überweißung/einzug</Text>
|
<Text>Überweißung/einzug</Text>
|
||||||
|
@ -1390,7 +1390,7 @@
|
||||||
<LineStrokeThickness>1</LineStrokeThickness>
|
<LineStrokeThickness>1</LineStrokeThickness>
|
||||||
</ConnectedShapesRecord>
|
</ConnectedShapesRecord>
|
||||||
<ConnectedShapesRecord>
|
<ConnectedShapesRecord>
|
||||||
<ObjectID>89c35f7ec6da4cb2ab3aa0a140072ad2</ObjectID>
|
<ObjectID>3a1636a08d2d490b994c871997b5f8d2</ObjectID>
|
||||||
<ParentShapeId>37eedc119a2c4e998b2254b25f4e7f87</ParentShapeId>
|
<ParentShapeId>37eedc119a2c4e998b2254b25f4e7f87</ParentShapeId>
|
||||||
<ChildShapeId>607ea9ee4a994d45bafe757014698907</ChildShapeId>
|
<ChildShapeId>607ea9ee4a994d45bafe757014698907</ChildShapeId>
|
||||||
<Text />
|
<Text />
|
||||||
|
@ -1457,7 +1457,7 @@
|
||||||
<LineStrokeThickness>1</LineStrokeThickness>
|
<LineStrokeThickness>1</LineStrokeThickness>
|
||||||
</ConnectedShapesRecord>
|
</ConnectedShapesRecord>
|
||||||
<ConnectedShapesRecord>
|
<ConnectedShapesRecord>
|
||||||
<ObjectID>0453fd09b0fe487f9cf3269c33fe18b7</ObjectID>
|
<ObjectID>5f7f0240d3ce4fce8be8c96fa29e45c7</ObjectID>
|
||||||
<ParentShapeId>b49af04e608549c89ac919c9d3e57c01</ParentShapeId>
|
<ParentShapeId>b49af04e608549c89ac919c9d3e57c01</ParentShapeId>
|
||||||
<ChildShapeId>1c6ab24e7855452dbfd83e71bee81fdf</ChildShapeId>
|
<ChildShapeId>1c6ab24e7855452dbfd83e71bee81fdf</ChildShapeId>
|
||||||
<Text />
|
<Text />
|
||||||
|
@ -1524,7 +1524,7 @@
|
||||||
<LineStrokeThickness>1</LineStrokeThickness>
|
<LineStrokeThickness>1</LineStrokeThickness>
|
||||||
</ConnectedShapesRecord>
|
</ConnectedShapesRecord>
|
||||||
<ConnectedShapesRecord>
|
<ConnectedShapesRecord>
|
||||||
<ObjectID>e75c504c385444ba85fb92fb362bdef3</ObjectID>
|
<ObjectID>be56c327a428475d8ec0f08fe3762004</ObjectID>
|
||||||
<ParentShapeId>a32ed2170b0d45968a4723b3a4f7e540</ParentShapeId>
|
<ParentShapeId>a32ed2170b0d45968a4723b3a4f7e540</ParentShapeId>
|
||||||
<ChildShapeId>a838e00032384ba2ab7988a1b0c7240e</ChildShapeId>
|
<ChildShapeId>a838e00032384ba2ab7988a1b0c7240e</ChildShapeId>
|
||||||
<Text>neue Aktivität festhalten</Text>
|
<Text>neue Aktivität festhalten</Text>
|
||||||
|
@ -1591,7 +1591,7 @@
|
||||||
<LineStrokeThickness>1</LineStrokeThickness>
|
<LineStrokeThickness>1</LineStrokeThickness>
|
||||||
</ConnectedShapesRecord>
|
</ConnectedShapesRecord>
|
||||||
<ConnectedShapesRecord>
|
<ConnectedShapesRecord>
|
||||||
<ObjectID>5b71a30b2b364ae7a464e252824f58f2</ObjectID>
|
<ObjectID>7c260adc1f304aebadd3f3d8b384f5e7</ObjectID>
|
||||||
<ParentShapeId>a32ed2170b0d45968a4723b3a4f7e540</ParentShapeId>
|
<ParentShapeId>a32ed2170b0d45968a4723b3a4f7e540</ParentShapeId>
|
||||||
<ChildShapeId>8e72f22161d94eeea283c0df0c41e557</ChildShapeId>
|
<ChildShapeId>8e72f22161d94eeea283c0df0c41e557</ChildShapeId>
|
||||||
<Text>Kontoauszugdrucken</Text>
|
<Text>Kontoauszugdrucken</Text>
|
||||||
|
@ -1658,7 +1658,7 @@
|
||||||
<LineStrokeThickness>1</LineStrokeThickness>
|
<LineStrokeThickness>1</LineStrokeThickness>
|
||||||
</ConnectedShapesRecord>
|
</ConnectedShapesRecord>
|
||||||
<ConnectedShapesRecord>
|
<ConnectedShapesRecord>
|
||||||
<ObjectID>b57dcdd387e84c869c1675485086ab9d</ObjectID>
|
<ObjectID>77e1677a2813444a8af0d88937495525</ObjectID>
|
||||||
<ParentShapeId>ffe8f01d912b4433830bce278888e1ee</ParentShapeId>
|
<ParentShapeId>ffe8f01d912b4433830bce278888e1ee</ParentShapeId>
|
||||||
<ChildShapeId>4fb53b4ee2304dc595ee36f22f68e83f</ChildShapeId>
|
<ChildShapeId>4fb53b4ee2304dc595ee36f22f68e83f</ChildShapeId>
|
||||||
<Text />
|
<Text />
|
||||||
|
@ -1725,7 +1725,7 @@
|
||||||
<LineStrokeThickness>1</LineStrokeThickness>
|
<LineStrokeThickness>1</LineStrokeThickness>
|
||||||
</ConnectedShapesRecord>
|
</ConnectedShapesRecord>
|
||||||
<ConnectedShapesRecord>
|
<ConnectedShapesRecord>
|
||||||
<ObjectID>5ee5579d6b784c4ca65effaf481c812b</ObjectID>
|
<ObjectID>f562f66f576141e6b0777bd7e1772993</ObjectID>
|
||||||
<ParentShapeId>4fb53b4ee2304dc595ee36f22f68e83f</ParentShapeId>
|
<ParentShapeId>4fb53b4ee2304dc595ee36f22f68e83f</ParentShapeId>
|
||||||
<ChildShapeId>610af0ac1b64468eb7db7c08b4503a4d</ChildShapeId>
|
<ChildShapeId>610af0ac1b64468eb7db7c08b4503a4d</ChildShapeId>
|
||||||
<Text />
|
<Text />
|
||||||
|
@ -1788,7 +1788,7 @@
|
||||||
<LineStrokeThickness>1</LineStrokeThickness>
|
<LineStrokeThickness>1</LineStrokeThickness>
|
||||||
</ConnectedShapesRecord>
|
</ConnectedShapesRecord>
|
||||||
<ConnectedShapesRecord>
|
<ConnectedShapesRecord>
|
||||||
<ObjectID>4af87af85f6a49f18470d308b24f2ec0</ObjectID>
|
<ObjectID>3c5fc781aa6a4985998521d1cbe138c2</ObjectID>
|
||||||
<ParentShapeId>8e72f22161d94eeea283c0df0c41e557</ParentShapeId>
|
<ParentShapeId>8e72f22161d94eeea283c0df0c41e557</ParentShapeId>
|
||||||
<ChildShapeId>d9ae231714074ef49b2560269b4e7405</ChildShapeId>
|
<ChildShapeId>d9ae231714074ef49b2560269b4e7405</ChildShapeId>
|
||||||
<Text>keine neuen Einträge</Text>
|
<Text>keine neuen Einträge</Text>
|
||||||
|
@ -1855,7 +1855,7 @@
|
||||||
<LineStrokeThickness>1</LineStrokeThickness>
|
<LineStrokeThickness>1</LineStrokeThickness>
|
||||||
</ConnectedShapesRecord>
|
</ConnectedShapesRecord>
|
||||||
<ConnectedShapesRecord>
|
<ConnectedShapesRecord>
|
||||||
<ObjectID>7b14420f07884668ababa8d2a79f6f5c</ObjectID>
|
<ObjectID>1b566d0dac84453aa0130fbc84ae8e65</ObjectID>
|
||||||
<ParentShapeId>8e72f22161d94eeea283c0df0c41e557</ParentShapeId>
|
<ParentShapeId>8e72f22161d94eeea283c0df0c41e557</ParentShapeId>
|
||||||
<ChildShapeId>ffe8f01d912b4433830bce278888e1ee</ChildShapeId>
|
<ChildShapeId>ffe8f01d912b4433830bce278888e1ee</ChildShapeId>
|
||||||
<Text>neue Einträge </Text>
|
<Text>neue Einträge </Text>
|
||||||
|
@ -1922,7 +1922,7 @@
|
||||||
<LineStrokeThickness>1</LineStrokeThickness>
|
<LineStrokeThickness>1</LineStrokeThickness>
|
||||||
</ConnectedShapesRecord>
|
</ConnectedShapesRecord>
|
||||||
<ConnectedShapesRecord>
|
<ConnectedShapesRecord>
|
||||||
<ObjectID>79722d87c9ea4d79a58ceeaac9168f6f</ObjectID>
|
<ObjectID>4b1046a6d0f64325b20d3bdd67227aed</ObjectID>
|
||||||
<ParentShapeId>d9ae231714074ef49b2560269b4e7405</ParentShapeId>
|
<ParentShapeId>d9ae231714074ef49b2560269b4e7405</ParentShapeId>
|
||||||
<ChildShapeId>610af0ac1b64468eb7db7c08b4503a4d</ChildShapeId>
|
<ChildShapeId>610af0ac1b64468eb7db7c08b4503a4d</ChildShapeId>
|
||||||
<Text />
|
<Text />
|
||||||
|
@ -1989,7 +1989,7 @@
|
||||||
<LineStrokeThickness>1</LineStrokeThickness>
|
<LineStrokeThickness>1</LineStrokeThickness>
|
||||||
</ConnectedShapesRecord>
|
</ConnectedShapesRecord>
|
||||||
<ConnectedShapesRecord>
|
<ConnectedShapesRecord>
|
||||||
<ObjectID>9e30629330e948838c8768991174bfe7</ObjectID>
|
<ObjectID>694b03e66529458eaaf6132cdd369a8d</ObjectID>
|
||||||
<ParentShapeId>610af0ac1b64468eb7db7c08b4503a4d</ParentShapeId>
|
<ParentShapeId>610af0ac1b64468eb7db7c08b4503a4d</ParentShapeId>
|
||||||
<ChildShapeId>1c6ab24e7855452dbfd83e71bee81fdf</ChildShapeId>
|
<ChildShapeId>1c6ab24e7855452dbfd83e71bee81fdf</ChildShapeId>
|
||||||
<Text />
|
<Text />
|
||||||
|
|
|
@ -7,11 +7,12 @@ import java.io.Serializable;
|
||||||
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, Girokonto> Girokonten = new HashMap<>();
|
||||||
|
|
||||||
public Bank(String name) {
|
public Bank(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
// instanceof Girokonto zum überprüfen der klassen zugehörigkeit
|
||||||
public void addKonto(Konto k) {
|
public void addKonto(Konto k) {
|
||||||
konten.put(k.getKontonummer(), k);
|
konten.put(k.getKontonummer(), k);
|
||||||
}
|
}
|
||||||
|
@ -25,27 +26,35 @@ public class Bank implements Serializable{
|
||||||
|
|
||||||
}
|
}
|
||||||
public long getKontostand(int Kontonummer) {
|
public long getKontostand(int Kontonummer) {
|
||||||
return konten.get(Kontonummer).getStand();
|
return konten.get(Kontonummer).getStand();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long GeldEinzahlen(int Kontonummer,double Betrag) {
|
public long GeldEinzahlen(int Kontonummer,double Betrag) {
|
||||||
return konten.get(Kontonummer).Einzahlen(Betrag);
|
return konten.get(Kontonummer).Einzahlen(Betrag);
|
||||||
|
|
||||||
}
|
}
|
||||||
public long Überweißen(int Kontonummer,double Betrag) {
|
public long Überweißen(int Kontonummer,double Betrag) {
|
||||||
return konten.get(Kontonummer).neueÜberweisung(Betrag, Kontonummer);
|
return Girokonten.get(Kontonummer).neueÜberweisung(Betrag, Kontonummer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void kontoAuszugerstellen(int Kontonummer) {
|
public void kontoAuszugerstellen(int Kontonummer) {
|
||||||
konten.get(Kontonummer).kontoAuszugerstellen();
|
konten.get(Kontonummer).kontoAuszugerstellen();
|
||||||
}
|
}
|
||||||
public void kontoÜberweisen(int Empfänger,int inhaber, double Menge) {
|
|
||||||
if(konten.get(inhaber).neueÜberweisung(Menge, Empfänger)>=0)
|
public long kontoÜberweisen(int Empfänger,int inhaber, double Menge) {
|
||||||
konten.get(Empfänger).Einzahlen(Menge);
|
|
||||||
|
if(konten.get(inhaber) instanceof Girokonto) {
|
||||||
|
if(((Girokonto) konten.get(inhaber)).neueÜberweisung(Menge, Empfänger)>=0)
|
||||||
|
konten.get(Empfänger).Einzahlen(Menge);
|
||||||
|
return konten.get(inhaber).getStand();
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
public long abheben(int kontonummer,double Menge) {
|
public long abheben(int kontonummer,double Menge) {
|
||||||
return konten.get(kontonummer).abbuchen(Menge);
|
return konten.get(kontonummer).abbuchen(Menge);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,13 +13,12 @@ import de.hs_mannheim.informatik.bank.facade.Banksystem;
|
||||||
|
|
||||||
public class Datenbank {
|
public class Datenbank {
|
||||||
File fp=new File("object.ser");
|
File fp=new File("object.ser");
|
||||||
ObjectOutputStream file;
|
|
||||||
|
|
||||||
|
|
||||||
public void Speichern(Bank bank) throws Exception{
|
public void Speichern(Bank bank) throws Exception{
|
||||||
|
|
||||||
file=new ObjectOutputStream(new FileOutputStream(fp));
|
ObjectOutputStream file=new ObjectOutputStream(new FileOutputStream(fp));
|
||||||
file.writeObject(bank);
|
file.writeObject(bank);
|
||||||
|
|
||||||
}
|
}
|
||||||
public Bank Laden() throws Exception{
|
public Bank Laden() throws Exception{
|
||||||
|
@ -30,22 +29,4 @@ public class Datenbank {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// public boolean fileExcists() {
|
|
||||||
// if(!fl.exists()) {
|
|
||||||
// try {
|
|
||||||
// boolean wurdeerstellt=fl.createNewFile();
|
|
||||||
// if(wurdeerstellt) {
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// }catch(IOException ex) {
|
|
||||||
// ex.printStackTrace();
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
package de.hs_mannheim.informatik.bank.domain;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class GiroKontenTests {
|
||||||
|
Bank bank;
|
||||||
|
Girokonto GK1=new Girokonto("Marc");
|
||||||
|
Girokonto GK2=new Girokonto("Marc");
|
||||||
|
Girokonto GK3=new Girokonto("Marc");
|
||||||
|
int a=GK1.getKontonummer();
|
||||||
|
int b =GK2.getKontonummer();
|
||||||
|
int c=GK3.getKontonummer();
|
||||||
|
|
||||||
|
Konto k1=new Konto("Marc");
|
||||||
|
Konto k2=new Konto("Marc");
|
||||||
|
Konto k3=new Konto("Marc");
|
||||||
|
int e=k1.getKontonummer();
|
||||||
|
int f=k2.getKontonummer();
|
||||||
|
int g=k3.getKontonummer();
|
||||||
|
@Before
|
||||||
|
public void Setup() {
|
||||||
|
bank=new Bank("Bank");
|
||||||
|
bank.addKonto(GK1);
|
||||||
|
bank.addKonto(GK2);
|
||||||
|
bank.addKonto(GK3);
|
||||||
|
bank.addKonto(k3);
|
||||||
|
bank.addKonto(k2);
|
||||||
|
bank.addKonto(k1);
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void Konto() {
|
||||||
|
|
||||||
|
assertEquals(bank.GeldEinzahlen(e, 654),654L);
|
||||||
|
assertEquals(bank.GeldEinzahlen(f, 654),654L);
|
||||||
|
assertEquals(bank.GeldEinzahlen(g, 654),654L);
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void Giro() {
|
||||||
|
|
||||||
|
|
||||||
|
assertEquals(bank.GeldEinzahlen(a, 654),654);
|
||||||
|
assertEquals(bank.GeldEinzahlen(b, 654),654);
|
||||||
|
assertEquals(bank.GeldEinzahlen(c, 654),654);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void abhebenTest() {
|
||||||
|
|
||||||
|
bank.GeldEinzahlen(a, 22);
|
||||||
|
bank.GeldEinzahlen(c, 4444);
|
||||||
|
bank.GeldEinzahlen(e, 6666);
|
||||||
|
assertEquals(bank.abheben(a, 1111),22);
|
||||||
|
assertEquals(bank.abheben(c, 2222),2222);
|
||||||
|
assertEquals(bank.abheben(e, 3333),3333);
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void überweißenTesten() {
|
||||||
|
bank.GeldEinzahlen(a, 3333);
|
||||||
|
bank.GeldEinzahlen(c, 4444);
|
||||||
|
bank.GeldEinzahlen(e, 6666);
|
||||||
|
|
||||||
|
assertEquals(bank.kontoÜberweisen(a,b,3333 ),bank.getKontostand(a));
|
||||||
|
assertEquals(bank.kontoÜberweisen(c,e,3333 ),bank.getKontostand(c));
|
||||||
|
assertEquals(bank.kontoÜberweisen(c,e,3333 ),-1);
|
||||||
|
assertEquals(bank.kontoÜberweisen(f,g,3333 ),bank.getKontostand(f));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package de.hs_mannheim.informatik.bank.domain;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class Girokonto extends Konto implements Serializable {
|
||||||
|
private int nummer;
|
||||||
|
private long stand = 0;
|
||||||
|
private String inhaber;
|
||||||
|
private Kontoauszug KA=new Kontoauszug();
|
||||||
|
|
||||||
|
public Girokonto(String inhaber) {
|
||||||
|
super(inhaber);
|
||||||
|
}
|
||||||
|
public long neueÜberweisung(double Menge,int Empfänger) {
|
||||||
|
if(Menge<=stand) {
|
||||||
|
KA.Hinzufügen(Menge, Empfänger);
|
||||||
|
return stand;
|
||||||
|
}
|
||||||
|
System.out.println("Nicht genug Geld vorhanden");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
|
@ -34,14 +34,7 @@ public class Konto implements Serializable{
|
||||||
public long getStand() {
|
public long getStand() {
|
||||||
return this.stand;
|
return this.stand;
|
||||||
}
|
}
|
||||||
public long neueÜberweisung(double Menge,int Empfänger) {
|
|
||||||
if(Menge<=stand) {
|
|
||||||
KA.Hinzufügen(Menge, Empfänger);
|
|
||||||
return stand;
|
|
||||||
}
|
|
||||||
System.out.println("Nicht genug Geld vorhanden");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
public void kontoAuszugerstellen() {
|
public void kontoAuszugerstellen() {
|
||||||
KA.Auszug();
|
KA.Auszug();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.util.Collection;
|
||||||
|
|
||||||
import de.hs_mannheim.informatik.bank.domain.Bank;
|
import de.hs_mannheim.informatik.bank.domain.Bank;
|
||||||
import de.hs_mannheim.informatik.bank.domain.Datenbank;
|
import de.hs_mannheim.informatik.bank.domain.Datenbank;
|
||||||
|
import de.hs_mannheim.informatik.bank.domain.Girokonto;
|
||||||
import de.hs_mannheim.informatik.bank.domain.Konto;
|
import de.hs_mannheim.informatik.bank.domain.Konto;
|
||||||
|
|
||||||
public class Banksystem {
|
public class Banksystem {
|
||||||
|
@ -14,22 +15,30 @@ public class Banksystem {
|
||||||
this.bank = new Bank(bankname);
|
this.bank = new Bank(bankname);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int kontoAnlegen(String name) {
|
public int kontoAnlegen(String name,boolean Giro) {
|
||||||
Konto k = new Konto(name);
|
if(Giro) {
|
||||||
bank.addKonto(k);
|
Girokonto gk = new Girokonto(name);
|
||||||
|
bank.addKonto(gk);
|
||||||
|
return gk.getKontonummer();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Konto k = new Konto(name);
|
||||||
|
bank.addKonto(k);
|
||||||
|
return k.getKontonummer();
|
||||||
|
}
|
||||||
|
|
||||||
return k.getKontonummer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String[] getKontenliste() {
|
public String[] getKontenliste() {
|
||||||
Collection<Konto> konten = bank.getKontenliste();
|
Collection<Konto> konten = bank.getKontenliste();
|
||||||
|
|
||||||
String[] liste = new String[konten.size()];
|
String[] liste = new String[konten.size()];
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Konto k : konten) {
|
for (Konto k : konten) {
|
||||||
liste[i++] = k.toString();
|
liste[i++] = k.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
return liste;
|
return liste;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +51,7 @@ public class Banksystem {
|
||||||
public long getKontostand(int Kontonummer) {
|
public long getKontostand(int Kontonummer) {
|
||||||
return bank.getKontostand(Kontonummer);
|
return bank.getKontostand(Kontonummer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void kontoAuszugerstellen(int Kontonummer) {
|
public void kontoAuszugerstellen(int Kontonummer) {
|
||||||
bank.kontoAuszugerstellen(Kontonummer);
|
bank.kontoAuszugerstellen(Kontonummer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,15 +11,15 @@ public class BanksystemTest {
|
||||||
@Test
|
@Test
|
||||||
public void Testcase1() {
|
public void Testcase1() {
|
||||||
Banksystem bs=new Banksystem("Testbank");
|
Banksystem bs=new Banksystem("Testbank");
|
||||||
int kontonummer=bs.kontoAnlegen("Marc");
|
int kontonummer=bs.kontoAnlegen("Marc",false);
|
||||||
System.out.println(kontonummer);
|
System.out.println(kontonummer);
|
||||||
Assert.assertEquals("erster Testcase einzahlen des mindestWerts",bs.Einzahlen(kontonummer, 1L),1L);
|
Assert.assertEquals("erster Testcase einzahlen des mindestWerts",bs.Einzahlen(kontonummer, 1L),1L);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void Testcase2() {
|
public void Testcase2() {
|
||||||
Banksystem bs=new Banksystem("Testbank");
|
Banksystem bs=new Banksystem("Testbank");
|
||||||
bs.kontoAnlegen("Marc");
|
bs.kontoAnlegen("Marc",false);
|
||||||
int kontonummer=bs.kontoAnlegen("Marc1");
|
int kontonummer=bs.kontoAnlegen("Marc1",true);
|
||||||
System.out.println(kontonummer);
|
System.out.println(kontonummer);
|
||||||
Assert.assertEquals("höchst Wert",bs.Einzahlen(kontonummer, 9999999999999999L),9999999999999999L);
|
Assert.assertEquals("höchst Wert",bs.Einzahlen(kontonummer, 9999999999999999L),9999999999999999L);
|
||||||
}
|
}
|
||||||
|
@ -27,9 +27,9 @@ public class BanksystemTest {
|
||||||
@Test
|
@Test
|
||||||
public void Testcase3() {
|
public void Testcase3() {
|
||||||
Banksystem bs=new Banksystem("Testbank");
|
Banksystem bs=new Banksystem("Testbank");
|
||||||
bs.kontoAnlegen("Marc");
|
bs.kontoAnlegen("Marc",false);
|
||||||
bs.kontoAnlegen("Marc1");
|
bs.kontoAnlegen("Marc1",true);
|
||||||
int kontonummer = bs.kontoAnlegen("Marc2");
|
int kontonummer = bs.kontoAnlegen("Marc2",false);
|
||||||
System.out.println(kontonummer);
|
System.out.println(kontonummer);
|
||||||
Assert.assertEquals("Test zum nichtbeachten Zahlen kleiner 0",bs.Einzahlen(kontonummer, -1L),0L);
|
Assert.assertEquals("Test zum nichtbeachten Zahlen kleiner 0",bs.Einzahlen(kontonummer, -1L),0L);
|
||||||
}
|
}
|
||||||
|
@ -37,50 +37,50 @@ public class BanksystemTest {
|
||||||
@Test
|
@Test
|
||||||
public void Testcase4() {
|
public void Testcase4() {
|
||||||
Banksystem bs=new Banksystem("Testbank");
|
Banksystem bs=new Banksystem("Testbank");
|
||||||
bs.kontoAnlegen("Marc");
|
bs.kontoAnlegen("Marc",true);
|
||||||
bs.kontoAnlegen("Marc1");
|
bs.kontoAnlegen("Marc1",false);
|
||||||
bs.kontoAnlegen("Marc2");
|
bs.kontoAnlegen("Marc2",true);
|
||||||
bs.kontoAnlegen("Marc3");
|
bs.kontoAnlegen("Marc3",false);
|
||||||
bs.kontoAnlegen("Marc4");
|
bs.kontoAnlegen("Marc4",true);
|
||||||
|
|
||||||
bs.kontoAnlegen("Marc5");
|
bs.kontoAnlegen("Marc5",false);
|
||||||
bs.kontoAnlegen("Marc6");
|
bs.kontoAnlegen("Marc6",true);
|
||||||
bs.kontoAnlegen("Marc7");
|
bs.kontoAnlegen("Marc7",false);
|
||||||
bs.kontoAnlegen("Marc8");
|
bs.kontoAnlegen("Marc8",true);
|
||||||
int kontonummer=bs.kontoAnlegen("Marc9");
|
int kontonummer=bs.kontoAnlegen("Marc9",false);
|
||||||
System.out.println(kontonummer);
|
System.out.println(kontonummer);
|
||||||
Assert.assertEquals("Höchstwert der Kontonummer testen",bs.Einzahlen(kontonummer, 1L),1L);
|
Assert.assertEquals("Höchstwert der Kontonummer testen",bs.Einzahlen(kontonummer, 1L),1L);
|
||||||
}
|
}
|
||||||
@Test(expected = NullPointerException.class)
|
@Test(expected = NullPointerException.class)
|
||||||
public void Testcase5() {
|
public void Testcase5() {
|
||||||
Banksystem bs=new Banksystem("Testbank");
|
Banksystem bs=new Banksystem("Testbank");
|
||||||
bs.kontoAnlegen("Marc");
|
bs.kontoAnlegen("Marc",false);
|
||||||
bs.kontoAnlegen("Marc1");
|
bs.kontoAnlegen("Marc1",true);
|
||||||
bs.kontoAnlegen("Marc2");
|
bs.kontoAnlegen("Marc2",false);
|
||||||
bs.kontoAnlegen("Marc3");
|
bs.kontoAnlegen("Marc3",true);
|
||||||
bs.kontoAnlegen("Marc4");
|
bs.kontoAnlegen("Marc4",false);
|
||||||
|
|
||||||
bs.kontoAnlegen("Marc5");
|
bs.kontoAnlegen("Marc5",true);
|
||||||
bs.kontoAnlegen("Marc6");
|
bs.kontoAnlegen("Marc6",false);
|
||||||
bs.kontoAnlegen("Marc7");
|
bs.kontoAnlegen("Marc7",true);
|
||||||
bs.kontoAnlegen("Marc8");
|
bs.kontoAnlegen("Marc8",false);
|
||||||
bs.kontoAnlegen("Marc9");
|
bs.kontoAnlegen("Marc9",true);
|
||||||
Assert.assertEquals("Fehlermeldung bei zukleiner Kontonummer",bs.Einzahlen(999, 1L),1L);
|
Assert.assertEquals("Fehlermeldung bei zukleiner Kontonummer",bs.Einzahlen(999, 1L),1L);
|
||||||
}
|
}
|
||||||
@Test(expected = NullPointerException.class)
|
@Test(expected = NullPointerException.class)
|
||||||
public void Testcase6() {
|
public void Testcase6() {
|
||||||
Banksystem bs=new Banksystem("Testbank");
|
Banksystem bs=new Banksystem("Testbank");
|
||||||
bs.kontoAnlegen("Marc");
|
bs.kontoAnlegen("Marc",true);
|
||||||
bs.kontoAnlegen("Marc1");
|
bs.kontoAnlegen("Marc1",true);
|
||||||
bs.kontoAnlegen("Marc2");
|
bs.kontoAnlegen("Marc2",true);
|
||||||
bs.kontoAnlegen("Marc3");
|
bs.kontoAnlegen("Marc3",true);
|
||||||
bs.kontoAnlegen("Marc4");
|
bs.kontoAnlegen("Marc4",true);
|
||||||
|
|
||||||
bs.kontoAnlegen("Marc5");
|
bs.kontoAnlegen("Marc5",false);
|
||||||
bs.kontoAnlegen("Marc6");
|
bs.kontoAnlegen("Marc6",false);
|
||||||
bs.kontoAnlegen("Marc7");
|
bs.kontoAnlegen("Marc7",false);
|
||||||
bs.kontoAnlegen("Marc8");
|
bs.kontoAnlegen("Marc8",false);
|
||||||
bs.kontoAnlegen("Marc9");
|
bs.kontoAnlegen("Marc9",false);
|
||||||
|
|
||||||
Assert.assertEquals("Fehlermeldung bei zu großer Kontonummer",bs.Einzahlen(1100, 1L),1L);
|
Assert.assertEquals("Fehlermeldung bei zu großer Kontonummer",bs.Einzahlen(1100, 1L),1L);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package de.hs_mannheim.informatik.bank.ui;
|
||||||
|
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
import de.hs_mannheim.informatik.bank.domain.Bank;
|
||||||
import de.hs_mannheim.informatik.bank.facade.Banksystem;
|
import de.hs_mannheim.informatik.bank.facade.Banksystem;
|
||||||
|
|
||||||
public class UI {
|
public class UI {
|
||||||
|
@ -67,14 +68,19 @@ public class UI {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void kontoAnlegen() {
|
private void kontoAnlegen() {
|
||||||
System.out.println("Bitte den Namen des Kontoinhabers angeben: ");
|
System.out.println("Soll das Konto ein Girokonto sein? Es macht das Überweißen zwischen Konten möglich: j/n");
|
||||||
String name = sc.nextLine();
|
String eingabe=sc.nextLine();
|
||||||
|
boolean Giro=eingabe.equals("j")||eingabe.equals("ja")||eingabe.equals("Ja")||eingabe.equals("J");
|
||||||
|
System.out.println("Bitte den Namen des Kontoinhabers angeben: ");
|
||||||
|
String name = sc.nextLine();
|
||||||
|
|
||||||
int kontonummer = bs.kontoAnlegen(name);
|
int kontonummer = bs.kontoAnlegen(name,Giro);
|
||||||
System.out.println("Konto mit der Nummer " + kontonummer + " neu angelegt.");
|
System.out.println("Konto mit der Nummer " + kontonummer + " neu angelegt.");
|
||||||
sc.nextLine();
|
sc.nextLine();
|
||||||
}
|
}
|
||||||
public void kontoEinzahlen() {
|
public void kontoEinzahlen() {
|
||||||
|
|
||||||
|
|
||||||
System.out.println("Kontonummer: ");
|
System.out.println("Kontonummer: ");
|
||||||
int Kontonummer=Integer.parseInt(sc.nextLine());
|
int Kontonummer=Integer.parseInt(sc.nextLine());
|
||||||
double Betrag=richtigerBetrag();
|
double Betrag=richtigerBetrag();
|
||||||
|
@ -126,7 +132,7 @@ public class UI {
|
||||||
|
|
||||||
double Betrag=richtigerBetrag();
|
double Betrag=richtigerBetrag();
|
||||||
|
|
||||||
if(existiertKonto(KontonummerE)&&Betrag!=0&&existiertKonto(KontonummerA)) {
|
if(existiertKonto(KontonummerA)&&Betrag!=0&&existiertKonto(KontonummerE)) {
|
||||||
bs.Überweisung(KontonummerE, KontonummerA, Betrag);
|
bs.Überweisung(KontonummerE, KontonummerA, Betrag);
|
||||||
}
|
}
|
||||||
sc.nextLine();
|
sc.nextLine();
|
||||||
|
@ -150,8 +156,7 @@ public class UI {
|
||||||
try {
|
try {
|
||||||
bs.getKontostand(Kontonummer);
|
bs.getKontostand(Kontonummer);
|
||||||
return true;
|
return true;
|
||||||
}
|
}catch(Exception NullPointerException){
|
||||||
catch(Exception NullPointerException) {
|
|
||||||
System.out.println("Konto mit der Nummer: "+Kontonummer+" existiert nicht");
|
System.out.println("Konto mit der Nummer: "+Kontonummer+" existiert nicht");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue