fixed bugs in TextOutput.java
This commit is contained in:
parent
94fa99d5b2
commit
70920b794a
|
@ -40,8 +40,8 @@ public class TextOutput {
|
||||||
* @param text the ArrayList which is used for the output.
|
* @param text the ArrayList which is used for the output.
|
||||||
*/
|
*/
|
||||||
private void toFormat(ArrayList<String> text) {
|
private void toFormat(ArrayList<String> text) {
|
||||||
int currentLength = 0;
|
|
||||||
for (String paragraph : text) {
|
for (String paragraph : text) {
|
||||||
|
int currentLength = 0;
|
||||||
String[] words = paragraph.split(" ");
|
String[] words = paragraph.split(" ");
|
||||||
int lastWordNumber = words.length;
|
int lastWordNumber = words.length;
|
||||||
int currentWordNumber = 0;
|
int currentWordNumber = 0;
|
||||||
|
@ -49,28 +49,20 @@ public class TextOutput {
|
||||||
currentWordNumber++;
|
currentWordNumber++;
|
||||||
if (word.length() <= columnWidth - currentLength) {
|
if (word.length() <= columnWidth - currentLength) {
|
||||||
System.out.print(word);
|
System.out.print(word);
|
||||||
if (!(lastWordNumber == currentWordNumber)) {
|
} else {
|
||||||
System.out.print(" ");
|
|
||||||
currentLength = currentLength + word.length() + 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
System.out.println();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
System.out.println();
|
System.out.println();
|
||||||
|
currentLength = 0;
|
||||||
System.out.print(word);
|
System.out.print(word);
|
||||||
|
}
|
||||||
if (!(currentWordNumber == lastWordNumber)) {
|
if (!(currentWordNumber == lastWordNumber)) {
|
||||||
System.out.print(" ");
|
System.out.print(" ");
|
||||||
currentLength = word.length() + 1;
|
currentLength = currentLength + word.length() + 1;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
System.out.println();
|
System.out.println();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method which sets the Variable formatRaw to true.
|
* Method which sets the Variable formatRaw to true.
|
||||||
|
@ -94,8 +86,7 @@ public class TextOutput {
|
||||||
formatRaw = false;
|
formatRaw = false;
|
||||||
columnWidth = length;
|
columnWidth = length;
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue