diff --git a/.idea/artifacts/Textanalyse_jar.xml b/.idea/artifacts/Textanalyse_jar.xml
new file mode 100644
index 0000000..0173beb
--- /dev/null
+++ b/.idea/artifacts/Textanalyse_jar.xml
@@ -0,0 +1,8 @@
+
+
+ $PROJECT_DIR$/out/artifacts/Textanalyse_jar
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 0856bb1..fcebfaf 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -1,11 +1,21 @@
+
+
+
+
+
-
+
+
+
+
+
+
@@ -31,8 +41,8 @@
-
-
+
+
@@ -41,12 +51,9 @@
-
-
-
-
-
-
+
+
+
@@ -64,8 +71,8 @@
-
-
+
+
@@ -94,8 +101,8 @@
-
-
+
+
@@ -123,8 +130,8 @@
-
+
@@ -165,6 +172,9 @@
+
+
+
@@ -183,6 +193,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -203,9 +227,6 @@
-
-
-
@@ -213,13 +234,16 @@
+
+
+
-
+
@@ -646,11 +670,12 @@
+
-
+
@@ -1081,40 +1106,114 @@
-
+
-
-
+
+
-
-
+
+
-
+
-
-
-
-
-
-
+
+
+
-
-
+
+
+
+
+
+
+
+ Textanalyse:jar
+
+
+
+
+
+
+
+ No facets are configured
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.8
+
+
+
+
+
+
+
+
+
+
+
+ Textanalyse
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/out/artifacts/Textanalyse_jar/Textanalyse.jar b/out/artifacts/Textanalyse_jar/Textanalyse.jar
new file mode 100644
index 0000000..abd5443
Binary files /dev/null and b/out/artifacts/Textanalyse_jar/Textanalyse.jar differ
diff --git a/out/production/Textanalyse/META-INF/MANIFEST.MF b/out/production/Textanalyse/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..8f9a234
--- /dev/null
+++ b/out/production/Textanalyse/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: com.structix.Main
+
diff --git a/out/production/Textanalyse/com/structix/Analyse.class b/out/production/Textanalyse/com/structix/Analyse.class
index 5181b31..9c8d237 100644
Binary files a/out/production/Textanalyse/com/structix/Analyse.class and b/out/production/Textanalyse/com/structix/Analyse.class differ
diff --git a/out/production/Textanalyse/com/structix/CommandLineInterface.class b/out/production/Textanalyse/com/structix/CommandLineInterface.class
index bf29723..11df709 100644
Binary files a/out/production/Textanalyse/com/structix/CommandLineInterface.class and b/out/production/Textanalyse/com/structix/CommandLineInterface.class differ
diff --git a/out/production/Textanalyse/com/structix/Main.class b/out/production/Textanalyse/com/structix/Main.class
index ca89f90..ccff005 100644
Binary files a/out/production/Textanalyse/com/structix/Main.class and b/out/production/Textanalyse/com/structix/Main.class differ
diff --git a/out/production/Textanalyse/com/structix/Menu.class b/out/production/Textanalyse/com/structix/Menu.class
index 5d153f9..e95b855 100644
Binary files a/out/production/Textanalyse/com/structix/Menu.class and b/out/production/Textanalyse/com/structix/Menu.class differ
diff --git a/src/META-INF/MANIFEST.MF b/src/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..8f9a234
--- /dev/null
+++ b/src/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: com.structix.Main
+
diff --git a/src/com/structix/Analyse.java b/src/com/structix/Analyse.java
index b6e67f7..4625c97 100644
--- a/src/com/structix/Analyse.java
+++ b/src/com/structix/Analyse.java
@@ -160,7 +160,7 @@ public class Analyse {
//Wenn Eintrag an der aktuellen Stelle kleiner wie an der nächsten Stelle ist,
//soll umsortiert (Plätze getauscht) werden
if (anz[z] < anz[z + 1]) {
- //Aktueller Eintrag wird ausgelagert
+ //Aktueller Eintrag wird ausgela-creditsgert
tempint = anz[z];
//Aktueller Eintrag wird mit dem nächsten Eintrag ersetzt
@@ -210,6 +210,53 @@ public class Analyse {
return (int) prozentsatz(anzBuchstabenMLeerzeichen() - anzBuchstabenOLeerzeichen(), anzBuchstabenMLeerzeichen());
}
+ public String textformatWoerter(int anzahlWoerter) {
+ String output = "";
+ int zaehler = 0;
+ for (int i = 0; i < woerterGesamt.length; i++) {
+ if (zaehler < anzahlWoerter) {
+ output += woerterGesamt[i] + " ";
+ zaehler++;
+ } else {
+ output += "\n";
+ zaehler = 0;
+ i--;
+ }
+ }
+ return output;
+ }
+
+ public String textFormatBuchstaben(int anzahlBuchstaben) {
+ String output = "";
+
+ if (laengstesWort() <= anzahlBuchstaben) {
+ int zeile = 0;
+ for (int i = 0; i < woerterGesamt.length; i++) {
+ zeile += woerterGesamt[i].length();
+ if (zeile <= anzahlBuchstaben) {
+ output += woerterGesamt[i] + " ";
+ } else {
+ output += "\n";
+ zeile = 0;
+ i--;
+ }
+ }
+ } else {
+ output = "Anzahl der Buchstaben muss mindestens dem längsten Wort entsprechen(" + laengstesWort() + " Zeichen).";
+ }
+ return output;
+ }
+
+
+ public int laengstesWort() {
+ int max = 0;
+ for (int i = 0; i < einzelneWoerter.length; i++) {
+ if (einzelneWoerter[i].length() > max) {
+ max = einzelneWoerter[i].length();
+ }
+ }
+ return max;
+ }
}
diff --git a/src/com/structix/CommandLineInterface.java b/src/com/structix/CommandLineInterface.java
index 4d65e75..b35e0b7 100644
--- a/src/com/structix/CommandLineInterface.java
+++ b/src/com/structix/CommandLineInterface.java
@@ -9,8 +9,11 @@ public class CommandLineInterface {
private String cmds[];
private String cmdseinzeln[];
- private String kommandos[] = {"-h", "-?", "--help", "--credits", "-w", "-v", "-b", "-ha"};
- private String hilfe[] = {"Hilfe", "Hilfe", "Hilfe", "Credits", "Anzahl der Wörter", "Anzahl der verwschiedenen Wörter", "Anzahl der Buchstaben", "Häufigkeit der Wörter"};
+ private String kommandos[] = {"-h", "-?", "--help", "--credits", "-w", "-v", "-b", "-ha", "-sl", "-tw", "-tb", "-tl"};
+ private String hilfe[] = {"Hilfe", "Hilfe", "Hilfe", "Credits", "Anzahl der Wörter",
+ "Anzahl der verwschiedenen Wörter", "Anzahl der Buchstaben", "Häufigkeit der Wörter",
+ "Anteil der Leerzeichen im Text", "Textformatierung nach Anzahl der Wörter pro Zeile",
+ "Textformatierung nach Anzahl der Buchstaben pro Zeile", "Textformatierung: Längstes Wort"};
String dateipfad = "";
int dateipfadstelle = -1;
@@ -59,11 +62,10 @@ public class CommandLineInterface {
public void ausfuehren() {
if (gueltigkeit()) {
-
+ Scanner eingabe = new Scanner(System.in);
String datei = dateipfad;
if (datei.isEmpty()) {
System.out.println("Geben Sie einen Dateipfad an (relativ sowie absolut erlaubt): ");
- Scanner eingabe = new Scanner(System.in);
datei = eingabe.nextLine();
}
Analyse an = new Analyse(datei);
@@ -92,6 +94,20 @@ public class CommandLineInterface {
case "-ha":
System.out.println(an.haeufigkeit());
break;
+ case "-sl":
+ System.out.println("Prozentsatz der enthaltenen Leerzeichen: " + an.stats_leerzeichen() + "%");
+ break;
+ case "-tw":
+ System.out.println("Geben Sie bitte die Anzahl der Wörter pro Zeile ein: ");
+ System.out.println(an.textformatWoerter(eingabe.nextInt()));
+ break;
+ case "-tb":
+ System.out.println("Geben Sie bitte die Anzahl der Zeichen pro Zeile ein: ");
+ System.out.println(an.textFormatBuchstaben(eingabe.nextInt()));
+ break;
+ case "-tl":
+ System.out.println("Buchstaben des längsten Wortes: " + an.laengstesWort());
+ break;
}
}
}
@@ -110,7 +126,7 @@ public class CommandLineInterface {
}
private String credits() {
- return "Muss noch geschrieben werden.";
+ return "Entwickler: Janek Schoffit";
}
diff --git a/src/com/structix/Main.java b/src/com/structix/Main.java
index 2af51cc..dfcf45f 100644
--- a/src/com/structix/Main.java
+++ b/src/com/structix/Main.java
@@ -28,6 +28,7 @@ package com.structix;
* 17.05.16: 11:59 - 12:37 Uhr
* 20.05.16: 11:18 - 12:32 Uhr
* 24:05.16: 17:46 - 19:17 Uhr
+ * 25.05.16: 10:47 - 11:32 Uhr
*/
public class Main {
diff --git a/src/com/structix/Menu.java b/src/com/structix/Menu.java
index 20654bd..1d2a15a 100644
--- a/src/com/structix/Menu.java
+++ b/src/com/structix/Menu.java
@@ -16,6 +16,9 @@ public class Menu {
//Objekte vom Menubuilder werden erzeugt und mit den Überschriften initialisiert.
Menubuilder mbuilder = new Menubuilder("Textanalyse");
Menubuilder statsmenu = new Menubuilder("Statistiken");
+ Menubuilder formatmenu = new Menubuilder("Textformatierung");
+
+ Scanner eingabe = new Scanner(System.in);
//Objekt der Analyse Klasse wird definiert.
//Es findet keine Deklaration statt, da dieses Objekt einen Dateipfad benötigt.
Analyse an;
@@ -29,7 +32,6 @@ public class Menu {
//Hier wird ein Dateipfad abgefragt
public void dateipfad() {
System.out.println("Geben Sie einen Dateipfad an (relativ sowie absolut erlaubt): ");
- Scanner eingabe = new Scanner(System.in);
//Instanz wird mit dem eingegebenen Dateipfad erstellt
an = new Analyse(eingabe.nextLine());
}
@@ -41,7 +43,7 @@ public class Menu {
int auswahl = 0;
//Menü wird mit Einträgen befüllt und auf das Ergebnis "gewartet"
//Die Zeichen für den Rahmen müssen auch angegeben werden
- auswahl = mbuilder.menuAnzeigen(new String[]{"Anzahl der Wörter", "Anzahl der verschiedenen Wörter", "Anzahl der Buchstaben", "Statistik Menü"}, "||");
+ auswahl = mbuilder.menuAnzeigen(new String[]{"Anzahl der Wörter", "Anzahl der verschiedenen Wörter", "Anzahl der Buchstaben", "Statistik Menü", "Textformatierung"}, "||");
switch (auswahl) {
case 1:
ausgabe("Anzahl der Wörter: " + an.laenge());
@@ -57,6 +59,10 @@ public class Menu {
//Aufruf eines weiteren Menüs
while (!statistikmenu());
break;
+ case 5:
+ //Aufruf des Untermenüs Textformatierung
+ while (!textformatmenu());
+ break;
default:
exit = true;
break; //Nicht zwingend notwendig
@@ -87,6 +93,33 @@ public class Menu {
return exit;
}
+ public boolean textformatmenu() {
+ boolean exit = false;
+ int auswahl = 0;
+ //Menü wird wieder mit Strings befüllt und der Rückgabe Wert der Variable auswahl zugeordnet
+ auswahl = formatmenu.menuAnzeigen(new String[]{"Nach Wörtern pro Zeile trennen", "Nach Anzahl der Buchstaben pro Zeile trennen", "Anzahl der Buchstaben des längsten Wortes"}, "||");
+ //Fallunterscheidung der Variable auswahl
+ switch (auswahl) {
+ case 1:
+ System.out.println("Geben Sie bitte die Anzahl der Wörter pro Zeile ein: ");
+ System.out.println(an.textformatWoerter(eingabe.nextInt()));
+ break;
+ case 2:
+ System.out.println("Geben Sie bitte die Anzahl der Zeichen pro Zeile ein: ");
+ System.out.println(an.textFormatBuchstaben(eingabe.nextInt()));
+ break;
+ case 3:
+ System.out.println("Buchstaben des längsten Wortes: " + an.laengstesWort());
+ break;
+ default:
+ exit = true;
+ break; //Nicht zwingend notwendig
+ }
+ //Boolean wird zurückgegeben
+ return exit;
+ }
+
+
//Methode zur einfacheren Ausgabe
private void ausgabe(String eing) {
System.out.println(eing);