akuteller Stand Übung, Teil 2 fast fertg und Teil 3 angefangen
parent
dfbba4bf7c
commit
177b73559e
|
@ -1 +1 @@
|
|||
Firmenname "Apple"Firmenadresse "US"Bankverbindung "DE12345"
|
||||
Firmenadresse = "nijokp"
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Firmenname "Google"Firmenadresse "US"Bankverbindung "US12456"
|
|
@ -1 +0,0 @@
|
|||
Firmenname "Google"Firmenadresse "US"Bankverbindung "US12345"
|
|
@ -1 +0,0 @@
|
|||
Firmenname = "HelloFresh"Firmenadresse = "Mannheim"Bankverbindung ="DE567788"
|
|
@ -1 +0,0 @@
|
|||
Firmenname = "dgfgfeg"Firmenadresse = "sfsfw"Bankverbindung ="eafedfw"
|
|
@ -1,3 +0,0 @@
|
|||
Firmenname = "fhhfd"
|
||||
Firmenadresse = "r4ffed"
|
||||
Bankverbindung ="4rfe224"
|
|
@ -2,8 +2,15 @@ package fakturierungssystem;
|
|||
|
||||
public class Datenmodell {
|
||||
private String firmenname;
|
||||
private String firmenadresse;
|
||||
private String strasse;
|
||||
private String hausnummer;
|
||||
private int plz;
|
||||
private String wohnort;
|
||||
private String land;
|
||||
private String bankverbindung;
|
||||
private int steuerid;
|
||||
|
||||
|
||||
|
||||
public String getFirmenname() {
|
||||
return firmenname;
|
||||
|
@ -11,17 +18,47 @@ public class Datenmodell {
|
|||
public void setFirmenname(String firmenname) {
|
||||
this.firmenname = firmenname;
|
||||
}
|
||||
public String getFirmenadresse() {
|
||||
return firmenadresse;
|
||||
}
|
||||
public void setFirmenadresse(String firmenadresse) {
|
||||
this.firmenadresse = firmenadresse;
|
||||
}
|
||||
public String getBankverbindung() {
|
||||
return bankverbindung;
|
||||
}
|
||||
public void setBankverbindung(String bankverbindung) {
|
||||
this.bankverbindung = bankverbindung;
|
||||
}
|
||||
public String getStrasse() {
|
||||
return strasse;
|
||||
}
|
||||
public void setStrasse(String strasse) {
|
||||
this.strasse = strasse;
|
||||
}
|
||||
public String getHausnummer() {
|
||||
return hausnummer;
|
||||
}
|
||||
public void setHausnummer(String hausnummer) {
|
||||
this.hausnummer = hausnummer;
|
||||
}
|
||||
public int getPlz() {
|
||||
return plz;
|
||||
}
|
||||
public void setPlz(int plz) {
|
||||
this.plz = plz;
|
||||
}
|
||||
public String getWohnort() {
|
||||
return wohnort;
|
||||
}
|
||||
public void setWohnort(String wohnort) {
|
||||
this.wohnort = wohnort;
|
||||
}
|
||||
public String getLand() {
|
||||
return land;
|
||||
}
|
||||
public void setLand(String land) {
|
||||
this.land = land;
|
||||
}
|
||||
public int getSteuerid() {
|
||||
return steuerid;
|
||||
}
|
||||
public void setSteuerid(int steuerid) {
|
||||
this.steuerid = steuerid;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,33 +1,48 @@
|
|||
package fakturierungssystem;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Persistierung {
|
||||
private static String cfgFile;
|
||||
File tempFile = new File(cfgFile);
|
||||
boolean exists = tempFile.exists();
|
||||
private static String cfgFile = "myconf.cfg";
|
||||
;
|
||||
BufferedWriter file;
|
||||
Datenmodell dm;
|
||||
|
||||
{
|
||||
if (exists == false) {
|
||||
try (BufferedWriter file = new BufferedWriter(new FileWriter(cfgFile))) {
|
||||
|
||||
public Persistierung() {
|
||||
dm = new Datenmodell();
|
||||
}
|
||||
|
||||
public void read() {
|
||||
try (BufferedReader file = new BufferedReader(new FileReader(cfgFile))) {
|
||||
System.out.println(file.readLine());
|
||||
dm.setFirmenname(file.readLine());
|
||||
// dm.setFirmenname(dm.getFirmenname().substring(dm.getFirmenname().indexOf(delimiter) + 1,
|
||||
// dm.getFirmenname().lastIndexOf(delimiter)));
|
||||
dm.setBankverbindung(file.readLine());
|
||||
// dm.setBankverbindung(dm.getBankverbindung().substring(dm.getBankverbindung().indexOf(delimiter) + 1, dm.getBankverbindung().lastIndexOf(delimiter)));
|
||||
System.out.println("Firma: " + dm.getFirmenname());
|
||||
System.out.println("Bank: " + dm.getBankverbindung());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void write(String satz) {
|
||||
try {
|
||||
FileWriter file = new FileWriter(cfgFile);
|
||||
file.write(satz);
|
||||
file.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
try {
|
||||
file.close();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package fakturierungssystem;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
public class UI {
|
||||
|
@ -7,19 +8,43 @@ public class UI {
|
|||
System.out.println("Willkommen!");
|
||||
Scanner sc = new Scanner(System.in);
|
||||
Persistierung ps = new Persistierung();
|
||||
Datenmodell dm = new Datenmodell();
|
||||
String cfgFile = "myconf.cfg";
|
||||
|
||||
File tempFile = new File(cfgFile);
|
||||
if (!tempFile.exists()) {
|
||||
System.out.println("Firmenname:");
|
||||
String firma = sc.nextLine();
|
||||
dm.setFirmenname(sc.nextLine());
|
||||
char quote = '"';
|
||||
ps.write("Firmenname = " + quote + firma + quote + "\n");
|
||||
System.out.println("Firmenadresse: ");
|
||||
String adresse = sc.nextLine();
|
||||
ps.write("Firmenadresse = " + quote + adresse + quote + "\n");
|
||||
ps.write("Firmenname = " + quote + dm.getFirmenname() + quote + "\n");
|
||||
System.out.println("Strasse = ");
|
||||
dm.setStrasse(sc.nextLine());
|
||||
ps.write("Firmenadresse = " + quote + dm.getStrasse() + quote + "\n");
|
||||
System.out.println("Hausnummer = ");
|
||||
dm.setHausnummer(sc.nextLine());
|
||||
ps.write("Hausnummer = " + quote + dm.getHausnummer() + quote + "\n");
|
||||
System.out.println("PLZ = ");
|
||||
dm.setPlz(sc.nextInt());
|
||||
ps.write("PLZ = " + quote + dm.getPlz() + quote + "\n");
|
||||
System.out.println("Wohnort = ");
|
||||
dm.setWohnort(cfgFile);
|
||||
ps.write("Strasse = " + quote + dm.getWohnort() + quote + "\n");
|
||||
System.out.println("Land = ");
|
||||
dm.setLand(sc.nextLine());
|
||||
ps.write("Land = " + quote + dm.getLand() + quote + "\n");
|
||||
System.out.println("Bankverbindung: ");
|
||||
String bank = sc.nextLine();
|
||||
ps.write("Bankverbindung =" + quote + bank + quote + "\n");
|
||||
dm.setBankverbindung(sc.nextLine());
|
||||
ps.write("Bankverbindung =" + quote + dm.getBankverbindung() + quote + "\n");
|
||||
System.out.println("SteuerID = ");
|
||||
dm.setSteuerid(sc.nextInt());
|
||||
ps.write("SteuerID = " + quote + dm.getSteuerid() + quote + "\n");
|
||||
System.out.println("Datei erfolgreich gespeichert");
|
||||
ps.close();
|
||||
|
||||
} else {
|
||||
ps.read();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,40 +4,87 @@ import java.io.*;
|
|||
|
||||
public class Datei {
|
||||
private int aktuell;
|
||||
private String dateiname;
|
||||
private int SATZLAENGE;
|
||||
private String dateiname = "Indexdatei.txt";
|
||||
private int SATZLAENGE = 100;
|
||||
private RandomAccessFile eineStammdatei;
|
||||
|
||||
public Datei() {
|
||||
|
||||
}
|
||||
|
||||
public Datei(String dateiname, int satzlänge) {
|
||||
SATZLAENGE = satzlänge;
|
||||
}
|
||||
|
||||
public void speichereSatz(String satz, int index) {
|
||||
try {
|
||||
positioniereAufSatz(index);
|
||||
writeFixedString(satz, SATZLAENGE);
|
||||
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String leseSatz(int index) {
|
||||
return null;
|
||||
try {
|
||||
positioniereAufSatz(index);
|
||||
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return readFixedString(SATZLAENGE);
|
||||
|
||||
}
|
||||
|
||||
public void öffneDatei(String name) {
|
||||
|
||||
|
||||
if (!name.isBlank())
|
||||
dateiname = name;
|
||||
try {
|
||||
eineStammdatei = new RandomAccessFile(dateiname, "rw");
|
||||
} catch (FileNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void schliesseDatei() {
|
||||
|
||||
try {
|
||||
eineStammdatei.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public int gibAnzahlDatensätze() {
|
||||
return 0;
|
||||
|
||||
return aktuell;
|
||||
}
|
||||
|
||||
private void positioniereAufSatz(int index) {
|
||||
|
||||
private void positioniereAufSatz(int index) throws IOException {
|
||||
eineStammdatei.seek(index * SATZLAENGE);
|
||||
}
|
||||
|
||||
private String readFixedString(int länge) {
|
||||
return null;
|
||||
StringBuffer satz = new StringBuffer();
|
||||
try {
|
||||
while (länge-- > 0)
|
||||
satz.append(eineStammdatei.readChar());
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return satz.toString();
|
||||
}
|
||||
|
||||
private void writeFixedString(String einDatensatz, int länge) {
|
||||
StringBuffer sb = new StringBuffer(einDatensatz);
|
||||
while (sb.length() != länge)
|
||||
sb.append("\0");
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
package indexverwaltung;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class IndexUI {
|
||||
Scanner sc = new Scanner(System.in);
|
||||
static File tempFile = new File("Datei.txt");
|
||||
static boolean exists = tempFile.exists();
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Willkommen! ");
|
||||
//wenn keine Datei existiert
|
||||
|
||||
Scanner sc = new Scanner(System.in);
|
||||
File tempFile = new File("Datei.txt");
|
||||
boolean exists = tempFile.exists();
|
||||
if (exists == false) {
|
||||
try (BufferedWriter file = new BufferedWriter(new FileWriter("Datei.txt"))) {
|
||||
|
||||
|
@ -19,6 +17,27 @@ public class IndexUI {
|
|||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
Datei datei = new Datei();
|
||||
Index index = new Index();
|
||||
System.out.println("Willkommen bei der Indexverwaltung: ");
|
||||
//wenn keine Datei existiert
|
||||
try {
|
||||
index.ladeIndexDatei();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("Datei lesen (j) oder Datei schreiben (n)");
|
||||
String eingabe;
|
||||
do {
|
||||
eingabe = sc.nextLine();
|
||||
} while (!(eingabe.equals("j")) || !(eingabe.equals("n")));
|
||||
if (eingabe.equals("j")) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue