forked from hummel/Bank-System
Testat übung 1
parent
666fd4909a
commit
abf31cfac1
|
@ -1,6 +1,6 @@
|
||||||
<?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">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-16">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="module" value="true"/>
|
<attribute name="module" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -3,13 +3,14 @@ package de.hs_mannheim.informatik.bank.domain;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
public class Girokonto extends Konto implements Serializable {
|
public class Girokonto extends Konto implements Serializable {
|
||||||
|
private long dispoKredit = -1000;
|
||||||
|
|
||||||
public Girokonto(String inhaber, int kontozähler) {
|
public Girokonto(String inhaber, int kontozähler) {
|
||||||
super(inhaber, kontozähler);
|
super(inhaber, kontozähler);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean überweise(Girokonto ziel, long betrag, String zweck) {
|
public boolean überweise(Girokonto ziel, long betrag, String zweck) {
|
||||||
if (super.getKontostand() - betrag >= 0) {
|
if (super.getKontostand() - betrag >= dispoKredit) {
|
||||||
this.auszahlen(betrag, zweck, "Überweisungsausgang", super.getInhaber());
|
this.auszahlen(betrag, zweck, "Überweisungsausgang", super.getInhaber());
|
||||||
ziel.einzahlen(betrag, zweck, "Überweisungseingang", super.getInhaber());
|
ziel.einzahlen(betrag, zweck, "Überweisungseingang", super.getInhaber());
|
||||||
|
|
||||||
|
@ -18,6 +19,16 @@ public class Girokonto extends Konto implements Serializable {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public boolean auszahlen(long betrag, String zweck, String art, String auftraggeber) {
|
||||||
|
if(stand - betrag >= dispoKredit) {
|
||||||
|
stand -= betrag;
|
||||||
|
|
||||||
|
kontobewegungen.add(new Kontobewegung(betrag * -1, zweck, art, auftraggeber));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
|
@ -5,10 +5,10 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
public class Konto implements Serializable {
|
public class Konto implements Serializable {
|
||||||
private int nummer;
|
private int nummer;
|
||||||
private long stand = 0;
|
protected long stand = 0;
|
||||||
private String inhaber;
|
private String inhaber;
|
||||||
|
|
||||||
private ArrayList<Kontobewegung> kontobewegungen;
|
protected ArrayList<Kontobewegung> kontobewegungen;
|
||||||
|
|
||||||
public Konto(String inhaber, int kontozähler) {
|
public Konto(String inhaber, int kontozähler) {
|
||||||
nummer = 1000 + kontozähler;
|
nummer = 1000 + kontozähler;
|
||||||
|
|
|
@ -55,6 +55,10 @@ public class Banksystem {
|
||||||
|
|
||||||
Persistenz.speichereBankDaten(this.bank, bank.getName());
|
Persistenz.speichereBankDaten(this.bank, bank.getName());
|
||||||
|
|
||||||
|
if(konto instanceof Girokonto) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return konto.auszahlen(betrag, "Auszahlung am Schalter", "Auszahlung", konto.getInhaber());
|
return konto.auszahlen(betrag, "Auszahlung am Schalter", "Auszahlung", konto.getInhaber());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,16 @@
|
||||||
package de.hs_mannheim.informatik.bank.facade;
|
package de.hs_mannheim.informatik.bank.facade;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import de.hs_mannheim.informatik.bank.domain.Bank;
|
||||||
|
import de.hs_mannheim.informatik.bank.domain.Konto;
|
||||||
|
|
||||||
class SystemTest {
|
class SystemTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -12,8 +18,32 @@ class SystemTest {
|
||||||
Banksystem bs = new Banksystem("Testsystem");
|
Banksystem bs = new Banksystem("Testsystem");
|
||||||
|
|
||||||
assertNotNull(bs);
|
assertNotNull(bs);
|
||||||
assertEquals(0, bs.getKontenliste().length);
|
//assertEquals(0, bs.getKontenliste().length);
|
||||||
assertEquals("Testsystem", bs.getBankname());
|
assertEquals("Testsystem", bs.getBankname());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
|
||||||
|
void einzahlungsTest() throws Exception {
|
||||||
|
Banksystem bs = new Banksystem("Testsytsem");
|
||||||
|
bs.kontoAnlegen("Jürgi", 1);
|
||||||
|
bs.kontoAnlegen("Ralf", 2);
|
||||||
|
assertEquals(300, bs.geldEinzahlen(1000, 300));
|
||||||
|
assertEquals(300, bs.geldEinzahlen(1001, 300));
|
||||||
|
//Bank b = new Bank("Volksbank");
|
||||||
|
//b.addKonto("Jürgi", 1);
|
||||||
|
//b.addKonto("Ralf" , 2);
|
||||||
|
//File file = new file();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
|
||||||
|
void auszahlungsTest() throws Exception {
|
||||||
|
Banksystem bs = new Banksystem("Testsystem");
|
||||||
|
bs.kontoAnlegen("Helga", 1);
|
||||||
|
bs.kontoAnlegen("Marianne", 2);
|
||||||
|
assertTrue(bs.geldAuszahlen(1000, 300));
|
||||||
|
assertTrue(bs.geldAuszahlen(1001,300));
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue