Speicher Funktion hinzugefügt. Sämtliche Sachen mit der speicherung

befinden sich in der Datenbank Klasse. Gespeichert wird die bank Klasse
Marc Ziegler 2022-10-11 14:43:49 +02:00
parent 287496085d
commit 301e12ade5
9 changed files with 110 additions and 38 deletions

View File

@ -921,7 +921,7 @@
<FreeLineShapes />
<ConnectedShapes>
<ConnectedShapesRecord>
<ObjectID>4a01937a48c7470e8ac02c06e117a9aa</ObjectID>
<ObjectID>810c924b577246088ff7a60dda51425b</ObjectID>
<ParentShapeId>5d0581b78aed4ee8b0bf6527c2681a23</ParentShapeId>
<ChildShapeId>4e970de88c214cf0b3635042b9e226fb</ChildShapeId>
<Text />
@ -988,7 +988,7 @@
<LineStrokeThickness>1</LineStrokeThickness>
</ConnectedShapesRecord>
<ConnectedShapesRecord>
<ObjectID>c51fb013ad584315a19eec9cf7701b9c</ObjectID>
<ObjectID>c56a5392fdcb4cb99bde4b0b7aca7069</ObjectID>
<ParentShapeId>4e970de88c214cf0b3635042b9e226fb</ParentShapeId>
<ChildShapeId>1c6ab24e7855452dbfd83e71bee81fdf</ChildShapeId>
<Text />
@ -1055,7 +1055,7 @@
<LineStrokeThickness>1</LineStrokeThickness>
</ConnectedShapesRecord>
<ConnectedShapesRecord>
<ObjectID>cd3ec870da1442d1902aa323aba0a6ee</ObjectID>
<ObjectID>a5e37ca5b6574a1ba47d13b50483c249</ObjectID>
<ParentShapeId>1c6ab24e7855452dbfd83e71bee81fdf</ParentShapeId>
<ChildShapeId>a32ed2170b0d45968a4723b3a4f7e540</ChildShapeId>
<Text />
@ -1122,7 +1122,7 @@
<LineStrokeThickness>1</LineStrokeThickness>
</ConnectedShapesRecord>
<ConnectedShapesRecord>
<ObjectID>aea20ea33bec424daf77ab0141d4c9cc</ObjectID>
<ObjectID>7a5dc86d6db2441cad85c4f6836ea3ff</ObjectID>
<ParentShapeId>607ea9ee4a994d45bafe757014698907</ParentShapeId>
<ChildShapeId>b49af04e608549c89ac919c9d3e57c01</ChildShapeId>
<Text />
@ -1189,7 +1189,7 @@
<LineStrokeThickness>1</LineStrokeThickness>
</ConnectedShapesRecord>
<ConnectedShapesRecord>
<ObjectID>92905a126e024a379bbff7451f53adcd</ObjectID>
<ObjectID>edf473f522ab4420b4518d563f340bbf</ObjectID>
<ParentShapeId>a838e00032384ba2ab7988a1b0c7240e</ParentShapeId>
<ChildShapeId>6ef27b03d235471db3d6ff4e8d96a5f2</ChildShapeId>
<Text>Daten der aktion</Text>
@ -1256,7 +1256,7 @@
<LineStrokeThickness>1</LineStrokeThickness>
</ConnectedShapesRecord>
<ConnectedShapesRecord>
<ObjectID>4d4f59cc79824433bf361a800ba1335a</ObjectID>
<ObjectID>e576b55981274419bf009ad25e69cbb1</ObjectID>
<ParentShapeId>6ef27b03d235471db3d6ff4e8d96a5f2</ParentShapeId>
<ChildShapeId>37eedc119a2c4e998b2254b25f4e7f87</ChildShapeId>
<Text>Abheben</Text>
@ -1323,7 +1323,7 @@
<LineStrokeThickness>1</LineStrokeThickness>
</ConnectedShapesRecord>
<ConnectedShapesRecord>
<ObjectID>5fd85cbf87274fe0bfa164493d1327fa</ObjectID>
<ObjectID>80fab382ef394d209427522726f56358</ObjectID>
<ParentShapeId>6ef27b03d235471db3d6ff4e8d96a5f2</ParentShapeId>
<ChildShapeId>37eedc119a2c4e998b2254b25f4e7f87</ChildShapeId>
<Text>Überweißung/einzug</Text>
@ -1390,7 +1390,7 @@
<LineStrokeThickness>1</LineStrokeThickness>
</ConnectedShapesRecord>
<ConnectedShapesRecord>
<ObjectID>eab38d6157d340be99046817cfbe8263</ObjectID>
<ObjectID>89c35f7ec6da4cb2ab3aa0a140072ad2</ObjectID>
<ParentShapeId>37eedc119a2c4e998b2254b25f4e7f87</ParentShapeId>
<ChildShapeId>607ea9ee4a994d45bafe757014698907</ChildShapeId>
<Text />
@ -1457,7 +1457,7 @@
<LineStrokeThickness>1</LineStrokeThickness>
</ConnectedShapesRecord>
<ConnectedShapesRecord>
<ObjectID>9543ce518fd3411280e68fe2231e1e08</ObjectID>
<ObjectID>0453fd09b0fe487f9cf3269c33fe18b7</ObjectID>
<ParentShapeId>b49af04e608549c89ac919c9d3e57c01</ParentShapeId>
<ChildShapeId>1c6ab24e7855452dbfd83e71bee81fdf</ChildShapeId>
<Text />
@ -1524,7 +1524,7 @@
<LineStrokeThickness>1</LineStrokeThickness>
</ConnectedShapesRecord>
<ConnectedShapesRecord>
<ObjectID>774c8acce1b94a73a915c4a4dd47d0bc</ObjectID>
<ObjectID>e75c504c385444ba85fb92fb362bdef3</ObjectID>
<ParentShapeId>a32ed2170b0d45968a4723b3a4f7e540</ParentShapeId>
<ChildShapeId>a838e00032384ba2ab7988a1b0c7240e</ChildShapeId>
<Text>neue Aktivität festhalten</Text>
@ -1591,7 +1591,7 @@
<LineStrokeThickness>1</LineStrokeThickness>
</ConnectedShapesRecord>
<ConnectedShapesRecord>
<ObjectID>cccf5b43d66b442a99958413ea6095bc</ObjectID>
<ObjectID>5b71a30b2b364ae7a464e252824f58f2</ObjectID>
<ParentShapeId>a32ed2170b0d45968a4723b3a4f7e540</ParentShapeId>
<ChildShapeId>8e72f22161d94eeea283c0df0c41e557</ChildShapeId>
<Text>Kontoauszugdrucken</Text>
@ -1658,7 +1658,7 @@
<LineStrokeThickness>1</LineStrokeThickness>
</ConnectedShapesRecord>
<ConnectedShapesRecord>
<ObjectID>c705a8a820ef490ca4e5251f196b6829</ObjectID>
<ObjectID>b57dcdd387e84c869c1675485086ab9d</ObjectID>
<ParentShapeId>ffe8f01d912b4433830bce278888e1ee</ParentShapeId>
<ChildShapeId>4fb53b4ee2304dc595ee36f22f68e83f</ChildShapeId>
<Text />
@ -1725,7 +1725,7 @@
<LineStrokeThickness>1</LineStrokeThickness>
</ConnectedShapesRecord>
<ConnectedShapesRecord>
<ObjectID>f927102877f7410d930d263370ac336c</ObjectID>
<ObjectID>5ee5579d6b784c4ca65effaf481c812b</ObjectID>
<ParentShapeId>4fb53b4ee2304dc595ee36f22f68e83f</ParentShapeId>
<ChildShapeId>610af0ac1b64468eb7db7c08b4503a4d</ChildShapeId>
<Text />
@ -1788,7 +1788,7 @@
<LineStrokeThickness>1</LineStrokeThickness>
</ConnectedShapesRecord>
<ConnectedShapesRecord>
<ObjectID>e3920325cecc441996e46d25cff4e5a1</ObjectID>
<ObjectID>4af87af85f6a49f18470d308b24f2ec0</ObjectID>
<ParentShapeId>8e72f22161d94eeea283c0df0c41e557</ParentShapeId>
<ChildShapeId>d9ae231714074ef49b2560269b4e7405</ChildShapeId>
<Text>keine neuen Einträge</Text>
@ -1855,7 +1855,7 @@
<LineStrokeThickness>1</LineStrokeThickness>
</ConnectedShapesRecord>
<ConnectedShapesRecord>
<ObjectID>92bde730fc44488382d00388dc9569a8</ObjectID>
<ObjectID>7b14420f07884668ababa8d2a79f6f5c</ObjectID>
<ParentShapeId>8e72f22161d94eeea283c0df0c41e557</ParentShapeId>
<ChildShapeId>ffe8f01d912b4433830bce278888e1ee</ChildShapeId>
<Text>neue Einträge </Text>
@ -1922,7 +1922,7 @@
<LineStrokeThickness>1</LineStrokeThickness>
</ConnectedShapesRecord>
<ConnectedShapesRecord>
<ObjectID>86f594cd861146a3bcfb9b686360c5ec</ObjectID>
<ObjectID>79722d87c9ea4d79a58ceeaac9168f6f</ObjectID>
<ParentShapeId>d9ae231714074ef49b2560269b4e7405</ParentShapeId>
<ChildShapeId>610af0ac1b64468eb7db7c08b4503a4d</ChildShapeId>
<Text />
@ -1989,7 +1989,7 @@
<LineStrokeThickness>1</LineStrokeThickness>
</ConnectedShapesRecord>
<ConnectedShapesRecord>
<ObjectID>ae1e79a26260481883efe9d7568f8af7</ObjectID>
<ObjectID>9e30629330e948838c8768991174bfe7</ObjectID>
<ParentShapeId>610af0ac1b64468eb7db7c08b4503a4d</ParentShapeId>
<ChildShapeId>1c6ab24e7855452dbfd83e71bee81fdf</ChildShapeId>
<Text />
@ -2482,7 +2482,7 @@
<FreeLineShapes />
<ConnectedShapes>
<ConnectedShapesRecord>
<ObjectID>fd14c93bc14141f99d623acda6e674f0</ObjectID>
<ObjectID>4631c244b7214707ae3893c33baa169e</ObjectID>
<ParentShapeId>672224f278704a4381e48874f64f1725</ParentShapeId>
<ChildShapeId>bea34833ed394b3c9302e5841fb58c3b</ChildShapeId>
<Text>1*</Text>
@ -2920,7 +2920,7 @@
<FreeLineShapes />
<ConnectedShapes>
<ConnectedShapesRecord>
<ObjectID>3a902849417a4ab781b16dda67233f15</ObjectID>
<ObjectID>951911c5ef1f41b9ba3e3adc53bf3373</ObjectID>
<ParentShapeId>5c182728429a45fb83b5769df4d6b599</ParentShapeId>
<ChildShapeId>747c149e0b294a9d806e98de4399660d</ChildShapeId>
<Text>hinzufügen()</Text>
@ -2987,7 +2987,7 @@
<LineStrokeThickness>1</LineStrokeThickness>
</ConnectedShapesRecord>
<ConnectedShapesRecord>
<ObjectID>be3e6b32e68b4f78b9def6e3b8b43029</ObjectID>
<ObjectID>c6640d786f794031a1beb04316ea5dd9</ObjectID>
<ParentShapeId>5c182728429a45fb83b5769df4d6b599</ParentShapeId>
<ChildShapeId>747c149e0b294a9d806e98de4399660d</ChildShapeId>
<Text>delete</Text>
@ -3054,7 +3054,7 @@
<LineStrokeThickness>1</LineStrokeThickness>
</ConnectedShapesRecord>
<ConnectedShapesRecord>
<ObjectID>b52978927a0043298046cdf53d3b2326</ObjectID>
<ObjectID>52141e978c9b42b595c9a5a166e6070c</ObjectID>
<ParentShapeId>5c182728429a45fb83b5769df4d6b599</ParentShapeId>
<ChildShapeId>ddd3bc6f429440deaae5fc26418736c5</ChildShapeId>
<Text>Ausgabe():String</Text>
@ -3121,7 +3121,7 @@
<LineStrokeThickness>1</LineStrokeThickness>
</ConnectedShapesRecord>
<ConnectedShapesRecord>
<ObjectID>7bd257e3336a4cdc8fa28b389d8b1964</ObjectID>
<ObjectID>217e0a84ec0a4949ab4d34c6fd3ceb66</ObjectID>
<ParentShapeId>ddd3bc6f429440deaae5fc26418736c5</ParentShapeId>
<ChildShapeId>5c182728429a45fb83b5769df4d6b599</ChildShapeId>
<Text>erstellen eines neuen kontos</Text>
@ -3188,7 +3188,7 @@
<LineStrokeThickness>1</LineStrokeThickness>
</ConnectedShapesRecord>
<ConnectedShapesRecord>
<ObjectID>9028a896f4504945b0d0493a38b3d813</ObjectID>
<ObjectID>18ccf5617f644dfd925b1c0a0a7db8e2</ObjectID>
<ParentShapeId>ddd3bc6f429440deaae5fc26418736c5</ParentShapeId>
<ChildShapeId>5c182728429a45fb83b5769df4d6b599</ChildShapeId>
<Text>delete():void</Text>
@ -3255,7 +3255,7 @@
<LineStrokeThickness>1</LineStrokeThickness>
</ConnectedShapesRecord>
<ConnectedShapesRecord>
<ObjectID>2b557de40a8f45f4b4fd3b29d147ef5a</ObjectID>
<ObjectID>58b8bdeeeeee4e5e823167cba046cfd1</ObjectID>
<ParentShapeId>ddd3bc6f429440deaae5fc26418736c5</ParentShapeId>
<ChildShapeId>5c182728429a45fb83b5769df4d6b599</ChildShapeId>
<Text>hinzufügen()void</Text>
@ -3322,7 +3322,7 @@
<LineStrokeThickness>1</LineStrokeThickness>
</ConnectedShapesRecord>
<ConnectedShapesRecord>
<ObjectID>3a82ef0b8f5c4298ac882cb7b5b17a82</ObjectID>
<ObjectID>a09de176aedf4cdf88e454f1cfea734b</ObjectID>
<ParentShapeId>747c149e0b294a9d806e98de4399660d</ParentShapeId>
<ChildShapeId>5c182728429a45fb83b5769df4d6b599</ChildShapeId>
<Text>Ausgeben():String</Text>

View File

@ -5,7 +5,7 @@ import de.hs_mannheim.informatik.bank.ui.UI;
public class Main {
public static void main(String[] args) {
public static void main(String[] args) throws Exception {
Banksystem bs = new Banksystem("Spaßkasse Mannheim");
UI ui = new UI(bs);
}

View File

@ -1,10 +1,11 @@
package de.hs_mannheim.informatik.bank.domain;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
public class Aktivität {
public class Aktivität implements Serializable{
private String Datum;
private String Ort;
private int Empfänger;

View File

@ -2,9 +2,9 @@ package de.hs_mannheim.informatik.bank.domain;
import java.util.Collection;
import java.util.HashMap;
import java.io.Serializable;
public class Bank {
public class Bank implements Serializable{
private String name;
private HashMap<Integer, Konto> konten = new HashMap<>();
@ -22,15 +22,19 @@ public class Bank {
public Collection<Konto> getKontenliste() {
return konten.values();
}
public long getKontostand(int Kontonummer) {
return konten.get(Kontonummer).getStand();
}
public long GeldEinzahlen(int Kontonummer,double Betrag) {
return konten.get(Kontonummer).Einzahlen(Betrag);
}
public long Überweißen(int Kontonummer,double Betrag) {
return konten.get(Kontonummer).neueÜberweisung(Betrag, Kontonummer);
}
public void kontoAuszugerstellen(int Kontonummer) {
konten.get(Kontonummer).kontoAuszugerstellen();
@ -41,6 +45,7 @@ public class Bank {
}
public long abheben(int kontonummer,double Menge) {
return konten.get(kontonummer).abbuchen(Menge);
}
}

View File

@ -0,0 +1,51 @@
package de.hs_mannheim.informatik.bank.domain;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.util.HashMap;
import java.io.IOException;
import java.io.ObjectInputStream;
import de.hs_mannheim.informatik.bank.facade.Banksystem;
public class Datenbank {
File fp=new File("object.ser");
ObjectOutputStream file;
public void Speichern(Bank bank) throws Exception{
file=new ObjectOutputStream(new FileOutputStream(fp));
file.writeObject(bank);
}
public Bank Laden() throws Exception{
if(fp.exists()) {
ObjectInputStream file=new ObjectInputStream(new FileInputStream(fp));
Bank object=(Bank)file.readObject();
return object;
}
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;
// }
}

View File

@ -1,6 +1,8 @@
package de.hs_mannheim.informatik.bank.domain;
public class Konto {
import java.io.Serializable;
public class Konto implements Serializable{
private static int kontozähler = 0;
private int nummer;
@ -11,7 +13,7 @@ public class Konto {
public Konto(String inhaber) {
nummer = 1000 + kontozähler++;
this.inhaber = inhaber;
//Kontoauszug KA=new Kontoauszug();
Kontoauszug KA=new Kontoauszug();
}
public int getKontonummer() {

View File

@ -1,8 +1,9 @@
package de.hs_mannheim.informatik.bank.domain;
import java.io.Serializable;
import java.util.ArrayList;
public class Kontoauszug {
public class Kontoauszug implements Serializable{
private ArrayList <Aktivität> Historie=new ArrayList();

View File

@ -3,10 +3,12 @@ package de.hs_mannheim.informatik.bank.facade;
import java.util.Collection;
import de.hs_mannheim.informatik.bank.domain.Bank;
import de.hs_mannheim.informatik.bank.domain.Datenbank;
import de.hs_mannheim.informatik.bank.domain.Konto;
public class Banksystem {
private Bank bank;
private Datenbank DB=new Datenbank();
public Banksystem(String bankname) {
this.bank = new Bank(bankname);
@ -49,4 +51,11 @@ public class Banksystem {
public void Überweisung(int Empfänger, int Sender,double Menge) {
bank.kontoÜberweisen(Empfänger, Sender, Menge);
}
public void Speichern() throws Exception {
DB.Speichern(bank);
}
public void Laden()throws Exception{
if(DB.Laden()!=null)
this.bank=DB.Laden();
}
}

View File

@ -8,9 +8,11 @@ public class UI {
private Banksystem bs;
Scanner sc = new Scanner(System.in);
public UI(Banksystem bs) {
public UI(Banksystem bs) throws Exception {
this.bs = bs;
Laden();
hauptmenü();
Speichern();
}
private void hauptmenü() {
@ -129,13 +131,14 @@ public class UI {
}
sc.nextLine();
}
public void Laden()throws Exception{
bs.Laden();
}
public void Speichern()throws Exception{
bs.Speichern();
}