diff --git a/src/Text.java b/src/Text.java index 60c830c..0f9c165 100644 --- a/src/Text.java +++ b/src/Text.java @@ -25,9 +25,6 @@ public class Text { * @return returns true if the given paragraph exists and is added successfully */ public boolean add(int paragraphNumber, String text) { - if(text.length() < 1) { - return false; - } if (paragraphExists(paragraphNumber)) { this.text.add((paragraphNumber - 1), text); return true; @@ -42,9 +39,6 @@ public class Text { * @return returns true if the paragraph is added successfully */ public boolean add(String text) { - if(text.length() < 1) { - return false; - } this.text.add(text.replaceAll("[^A-Za-z0-9 .,:?!\"'-]","")); return true; } diff --git a/src/TextLogik.java b/src/TextLogik.java index a8682c8..9bd8f88 100644 --- a/src/TextLogik.java +++ b/src/TextLogik.java @@ -12,21 +12,25 @@ public class TextLogik { textOutput = new TextOutput(); String[] command; - textOutput.userInfoOutput("######################"); + textOutput.userInfoOutput("#######################"); textOutput.userInfoOutput("#WELCOME TO THE EDITOR#"); - textOutput.userInfoOutput("######################"); + textOutput.userInfoOutput("#######################"); do { textOutput.userInfoOutput("Please enter a Command: "); command = TextInput.checkForInput(); switch (command[0]) { case "ADD": - textOutput.userInfoOutput("Please enter your text: "); + String inputText = ""; + while(inputText.length() == 0) { + textOutput.userInfoOutput("Please enter your text: "); + inputText = TextInput.getTextInput(); + } if (command.length == 1) { - checkIfSuccess(text.add(TextInput.getTextInput())); + checkIfSuccess(text.add(inputText)); } else if (isNumeric(command[1])) { int line = Integer.parseInt(command[1]); - checkIfSuccess(text.add(line, TextInput.getTextInput())); + checkIfSuccess(text.add(line, inputText)); } else { textOutput.errorInvalidCommand(); }