UI + ConfigDatei
parent
a085c73e7e
commit
78cbfdd27e
|
@ -15,14 +15,14 @@ public class ConfigDatei {
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
Scanner sc = new Scanner(System.in);
|
Scanner sc = new Scanner(System.in);
|
||||||
File tmpFile = new File("C:\\Users\\Tim\\OneDrive\\Desktop\\b.txt");
|
File tmpFile = new File("C:\\Users\\Tim\\OneDrive\\Desktop\\configu.txt");
|
||||||
char quote = '"';
|
char quote = '"';
|
||||||
|
|
||||||
if (!tmpFile.exists()) {
|
if (!tmpFile.exists()) {
|
||||||
try {
|
try {
|
||||||
tmpFile.createNewFile();
|
tmpFile.createNewFile();
|
||||||
BufferedWriter bw = new BufferedWriter(new FileWriter(tmpFile));
|
BufferedWriter bw = new BufferedWriter(new FileWriter(tmpFile));
|
||||||
System.out.println("Bitte geben sie Ihren Firmennamen ein: ");//Benutzereingaben
|
System.out.println("Bitte geben sie Ihren Firmennamen ein: ");// Benutzereingaben
|
||||||
String name = sc.nextLine();
|
String name = sc.nextLine();
|
||||||
System.out.println("Bitte geben sie Ihre Firmenadresse ein: ");
|
System.out.println("Bitte geben sie Ihre Firmenadresse ein: ");
|
||||||
String adresse = sc.nextLine();
|
String adresse = sc.nextLine();
|
||||||
|
@ -30,11 +30,11 @@ public class ConfigDatei {
|
||||||
String bankverbindung = sc.nextLine();
|
String bankverbindung = sc.nextLine();
|
||||||
System.out.println("Bitte geben Sie ihr Land ein: ");
|
System.out.println("Bitte geben Sie ihr Land ein: ");
|
||||||
String land = sc.nextLine();
|
String land = sc.nextLine();
|
||||||
bw.write("Firmenname= " + quote + name + quote + "\n");//in datei schreiben schreiben
|
bw.write("Firmenname= " + quote + name + quote + "\n");// in datei schreiben schreiben
|
||||||
bw.write("Firmenadresse= " + quote + adresse + quote + "\n");
|
bw.write("Firmenadresse= " + quote + adresse + quote + "\n");
|
||||||
bw.write("Bankverbindung= " + quote + bankverbindung + quote + "\n");
|
bw.write("Bankverbindung= " + quote + bankverbindung + quote + "\n");
|
||||||
bw.write("Land= " + quote + land + quote + "\n");
|
bw.write("Land= " + quote + land + quote + "\n");
|
||||||
bw.close();//bw schließen
|
bw.close();// bw schließen
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -49,6 +49,9 @@ public class ConfigDatei {
|
||||||
String zeile;
|
String zeile;
|
||||||
while ((zeile = br.readLine()) != null) {
|
while ((zeile = br.readLine()) != null) {
|
||||||
String werte[] = zeile.split("=");
|
String werte[] = zeile.split("=");
|
||||||
|
String name = werte[0];
|
||||||
|
String value = werte[1].replace(quote, ' ').trim();
|
||||||
|
System.out.println(name + ":" + value);
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class UI2 {
|
||||||
|
private Datei daten;
|
||||||
|
private Scanner sc = new Scanner(System.in);
|
||||||
|
|
||||||
|
public UI2(Datei daten) {
|
||||||
|
this.daten=daten;
|
||||||
|
start();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void start() {
|
||||||
|
System.out.println("Hallo");
|
||||||
|
mainloop: while (true) {
|
||||||
|
System.out.println("Bitte wählen Sie eine Aktion:");
|
||||||
|
System.out.println("1 -> Satz speichern");
|
||||||
|
System.out.println("2 -> Satz lesen");
|
||||||
|
System.out.println("3 -> Anzahl Datensätze anzeigen");
|
||||||
|
System.out.println("4 -> Datenbank schließen");
|
||||||
|
|
||||||
|
|
||||||
|
System.out.print("> ");
|
||||||
|
int input = Integer.parseInt(sc.nextLine());
|
||||||
|
System.out.println();
|
||||||
|
try {
|
||||||
|
switch (input) {
|
||||||
|
case 1:
|
||||||
|
speichereSatz();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
leseSatz();
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
break mainloop;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println(e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void leseSatz() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void speichereSatz() throws IOException {
|
||||||
|
System.out.println("Bitte gebe einen Satz ein: ");
|
||||||
|
String satz = sc.nextLine();
|
||||||
|
daten.speichereSatz(satz, daten.gibAnzahlDatensätze());
|
||||||
|
System.out.println("Satz gespeichert");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue