added error method missing text and implemented indexOutput and print to throw it when empty

This commit is contained in:
Leonardo Brandenberger 2021-11-11 22:10:33 +01:00
parent 3e2bfbaf42
commit fc2df13790
1 changed files with 18 additions and 3 deletions

View File

@ -14,7 +14,10 @@ public class TextOutput {
* @param text the ArrayList which is then formatted into the desired output.
*/
public void print(ArrayList<String> text) {
if (formatRaw) {
if(text.size() == 0) {
errorMissingText();
}
else if (formatRaw) {
printFormated(text);
} else {
toFormat(text);
@ -112,10 +115,15 @@ public class TextOutput {
* @param index ArrayList with words and in which part they have
*/
public void indexOutput(ArrayList<String> index) {
if(index.size() == 0) {
errorMissingText();
}
else {
for (String word : index) {
System.out.println(word);
}
}
}
/**
* Method to give out the Error "Invalid Paragraph".
@ -130,4 +138,11 @@ public class TextOutput {
public void errorInvalidCommand() {
System.err.println("Invalid Command");
}
/**
* Method to give out the Error "Missing Text".
*/
public void errorMissingText() {
System.err.println("Missing Text");
}
}