added unique error message to invalid format length

This commit is contained in:
Andrin Fassbind 2021-11-12 08:50:03 +01:00
parent 547db94893
commit 8225111671
3 changed files with 4 additions and 5 deletions

View File

@ -166,7 +166,6 @@ public class Text {
/** /**
* This method counts all Words in text and adds the count together with the paragraph where the word is been used to a Hashmap. * This method counts all Words in text and adds the count together with the paragraph where the word is been used to a Hashmap.
* *
* @return HashMap<String, ArrayList < Integer>>
*/ */
private void createWordlist(HashMap<String,ArrayList<Integer>> wordbook) { private void createWordlist(HashMap<String,ArrayList<Integer>> wordbook) {
int counter; int counter;

View File

@ -62,7 +62,7 @@ public class TextLogik {
if (command.length > 1 && "RAW".equals(command[1])) { if (command.length > 1 && "RAW".equals(command[1])) {
checkIfSuccess(textOutput.formatRaw()); checkIfSuccess(textOutput.formatRaw());
} else if (command.length > 2 && "FIX".equals(command[1]) && isNumeric(command[2])) { } else if (command.length > 2 && "FIX".equals(command[1]) && isNumeric(command[2])) {
checkIfSuccess(textOutput.formatFix(Integer.parseInt(command[2]))); textOutput.formatFix(Integer.parseInt(command[2]));
} else { } else {
textOutput.errorInvalidCommand(); textOutput.errorInvalidCommand();
} }

View File

@ -89,14 +89,14 @@ public class TextOutput {
* @param length the paragraph length when printing the text. * @param length the paragraph length when printing the text.
* @return returns true if successful and false if and invalid length has been submitted. * @return returns true if successful and false if and invalid length has been submitted.
*/ */
public boolean formatFix(int length) { public void formatFix(int length) {
if(length > 0) { if(length > 0) {
formatRaw = false; formatRaw = false;
columnWidth = length; columnWidth = length;
return true; userInfoOutput("Command was successfull");
} }
else { else {
return false; System.err.println("Minimum length has to be greater than 0");
} }
} }