removed old toFormat Method
This commit is contained in:
parent
300d41c53d
commit
e96f492386
|
@ -14,7 +14,7 @@ public class TextOutput {
|
|||
if (formatRaw) {
|
||||
printFormated(text);
|
||||
} else {
|
||||
toFormat4(text);
|
||||
toFormat(text);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,25 +29,6 @@ public class TextOutput {
|
|||
}
|
||||
|
||||
}
|
||||
private void toFormat2(ArrayList<String> text) {
|
||||
for (String para : text) {
|
||||
String[] words = para.split(" ");
|
||||
String output = "";
|
||||
for (String word : words) {
|
||||
if ((output.length() + word.length()) < columnWidth) {
|
||||
output += "word ";
|
||||
} else {
|
||||
if (word.length() <= columnWidth) {
|
||||
System.out.println(output);
|
||||
output = "";
|
||||
} else {
|
||||
System.out.println(word.substring(0, columnWidth) );//+ "-");
|
||||
output = word.substring(columnWidth);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to print out the paragraphs with the length taken from columnWidth and adding leftover words to the next
|
||||
|
@ -55,7 +36,7 @@ public class TextOutput {
|
|||
*
|
||||
* @param text the ArrayList which is used for the output.
|
||||
*/
|
||||
private void toFormat(ArrayList<String> text) {
|
||||
private void toFormatold(ArrayList<String> text) {
|
||||
for (String paragraph : text) {
|
||||
String[] words = paragraph.split(" ");
|
||||
int currentLength = 0;
|
||||
|
@ -92,7 +73,7 @@ public class TextOutput {
|
|||
System.out.println(); //added
|
||||
}
|
||||
}
|
||||
private void toFormat4(ArrayList<String> text) {
|
||||
private void toFormat(ArrayList<String> text) {
|
||||
int currentLength = 0;
|
||||
for (String paragraph : text) {
|
||||
String[] words = paragraph.split(" ");
|
||||
|
@ -109,15 +90,11 @@ public class TextOutput {
|
|||
else {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
System.out.println();
|
||||
System.out.print(word);
|
||||
if(currentWordNumber == lastwordNumber) {
|
||||
//System.out.println();
|
||||
}
|
||||
else {
|
||||
if(!(currentWordNumber == lastwordNumber)) {
|
||||
System.out.print(" ");
|
||||
currentLength = word.length();
|
||||
}
|
||||
|
@ -126,54 +103,6 @@ public class TextOutput {
|
|||
}
|
||||
}
|
||||
|
||||
private void toFormat3(ArrayList<String> text) {
|
||||
for(String paragraph : text) {
|
||||
if (paragraph.length() <= columnWidth) {
|
||||
System.out.println(paragraph);
|
||||
}
|
||||
else {
|
||||
String[] word = paragraph.split(" ");
|
||||
int currentLineLength = 0;
|
||||
for(String eachword : word) {
|
||||
if (eachword.length() > columnWidth) {
|
||||
String remainingText = eachword;
|
||||
do {
|
||||
if (remainingText.length() < columnWidth) {
|
||||
System.out.println(remainingText);
|
||||
break;
|
||||
}
|
||||
System.out.println(remainingText.substring(0, columnWidth));
|
||||
remainingText = remainingText.substring((columnWidth));
|
||||
|
||||
} while (!(remainingText.length() == 0));
|
||||
}
|
||||
else {
|
||||
if (currentLineLength == 0) {
|
||||
System.out.println();
|
||||
}
|
||||
if (columnWidth > eachword.length()) {
|
||||
System.out.print(eachword);
|
||||
if (!(currentLineLength == columnWidth)) {
|
||||
System.out.print(" ");
|
||||
}
|
||||
currentLineLength = currentLineLength + eachword.length();
|
||||
}
|
||||
else {
|
||||
System.out.println(eachword);
|
||||
currentLineLength = eachword.length();
|
||||
if (!(currentLineLength == columnWidth)) {
|
||||
System.out.print(" ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Method which sets the Variable formatRaw to true.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue