Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
55fd84380b
|
@ -33,43 +33,6 @@ public class TextOutput {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toFormatold(ArrayList<String> text) {
|
|
||||||
for (String paragraph : text) {
|
|
||||||
String[] words = paragraph.split(" ");
|
|
||||||
int currentLength = 0;
|
|
||||||
for (String word : words) {
|
|
||||||
if (word.length() > columnWidth) {
|
|
||||||
String[] letters = word.split("");
|
|
||||||
int letterLenght = letters.length;
|
|
||||||
int lettersPrinted = 0;
|
|
||||||
do {
|
|
||||||
currentLength = 0;
|
|
||||||
for (int i = 0; i < columnWidth; i++) {
|
|
||||||
if (letterLenght > 0) {
|
|
||||||
System.out.print(letters[lettersPrinted]);
|
|
||||||
letterLenght--;
|
|
||||||
lettersPrinted++;
|
|
||||||
currentLength++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!(letterLenght == 0)) {
|
|
||||||
System.out.println();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (letterLenght >= columnWidth);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if (word.length() >= columnWidth - currentLength) {
|
|
||||||
currentLength = 0;
|
|
||||||
System.out.println();
|
|
||||||
}
|
|
||||||
System.out.print(word + " ");
|
|
||||||
currentLength += word.length() + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.out.println(); //added
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Method to print out the paragraphs with the length taken from columnWidth and adding leftover words to the next
|
* Method to print out the paragraphs with the length taken from columnWidth and adding leftover words to the next
|
||||||
* paragraph.
|
* paragraph.
|
||||||
|
|
Loading…
Reference in New Issue