forked from hummel/Bank-System
kann zerstört werden
parent
4d2b4ec074
commit
31429a0998
|
@ -0,0 +1,30 @@
|
|||
package de.hs_mannheim.informatik.bank.domain;
|
||||
|
||||
public class Aktien {
|
||||
|
||||
private static int id = 0;
|
||||
private String name;
|
||||
private long kosten;
|
||||
private String inhaber;
|
||||
|
||||
public Aktien(String name, long kosten, String inhaber) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.kosten = kosten;
|
||||
this.inhaber = inhaber;
|
||||
id++;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setInhaber(String inhaber) {
|
||||
this.inhaber = inhaber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Name: " + name + " Kosten: " + kosten + " Inhaber: "+ inhaber;
|
||||
}
|
||||
}
|
|
@ -4,12 +4,18 @@ import java.io.Serializable;
|
|||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.hamcrest.core.IsInstanceOf;
|
||||
|
||||
import de.hs_mannheim.informatik.bank.facade.Banksystem;
|
||||
import de.hs_mannheim.informatik.bank.ui.UI;
|
||||
|
||||
|
||||
|
||||
public class Bank implements Serializable {
|
||||
private String name;
|
||||
private HashMap<Integer, Konto> konten = new HashMap<>();
|
||||
private HashMap<Integer, Kunde> kunden = new HashMap<>();
|
||||
private HashMap<Integer, Aktien> wertpapiere = new HashMap<>();
|
||||
private int kontozähler;
|
||||
|
||||
public Bank(String name) {
|
||||
|
@ -17,6 +23,28 @@ public class Bank implements Serializable {
|
|||
this.kontozähler = -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void kaufeAktien(int kontonummer, int idAktien) {
|
||||
Aktien ak1 = new Aktien("WertTest",10,"bob");
|
||||
Aktien ak2 = new Aktien("WertTest2",10,"otto");
|
||||
Girokonto gr = new Girokonto("Paul", 1020);
|
||||
Girokonto gr2 = new Girokonto("Blubb", 1021);
|
||||
gr.einzahlen(10000, name, name, name);
|
||||
gr2.einzahlen(10000, name, name, name);
|
||||
wertpapiere.put(ak1.getId(),ak1);
|
||||
wertpapiere.put(ak2.getId(),ak2);
|
||||
|
||||
Depot kd = (Depot) konten.get(kontonummer);
|
||||
Aktien ak = wertpapiere.get(idAktien);
|
||||
System.out.println(ak.toString());
|
||||
if(kd instanceof Depot) {
|
||||
kd.kaufeAktien(gr2, ak);
|
||||
ak.setInhaber(kd.getInhaber());
|
||||
System.out.println(ak.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public int addKonto(String name, int auswahl , int id) {
|
||||
Konto k;
|
||||
|
||||
|
@ -60,4 +88,5 @@ public class Bank implements Serializable {
|
|||
public Collection<Kunde> getKundenListe() {
|
||||
return kunden.values();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package de.hs_mannheim.informatik.bank.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Depot extends Girokonto {
|
||||
|
||||
private ArrayList<Aktien> wertpapiere = new ArrayList<>();
|
||||
|
||||
public Depot(String inhaber, int kontozähler) {
|
||||
super(inhaber, kontozähler);
|
||||
}
|
||||
|
||||
public boolean kaufeAktien(Girokonto g, Aktien ak) {
|
||||
boolean erfolgreich = super.überweise(g, stand, getInhaber());
|
||||
if(erfolgreich) {
|
||||
wertpapiere.add(ak);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public ArrayList<Aktien> getWertpapiere() {
|
||||
return wertpapiere;
|
||||
}
|
||||
}
|
|
@ -1,8 +1,9 @@
|
|||
package de.hs_mannheim.informatik.bank.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Kunde {
|
||||
public class Kunde implements Serializable{
|
||||
|
||||
private static int id = 0;
|
||||
private String vorname;
|
||||
|
|
Loading…
Reference in New Issue