diff --git a/src/Text.java b/src/Text.java index 108d703..902a39a 100644 --- a/src/Text.java +++ b/src/Text.java @@ -39,7 +39,7 @@ public class Text { * @return returns true if the paragraph is added successfully */ public boolean add(String text) { - this.text.add(text); + this.text.add(text.replaceAll("[^A-Za-z0-9 .,:?!\"'-]","")); return true; } @@ -168,7 +168,7 @@ public class Text { String firstLetter; String restLetters; for (int i = 0; i < text.size(); i++) { - String[] words = text.get(i).trim().toLowerCase().split("[ :;.,!?><'/\n]+"); + String[] words = text.get(i).trim().toLowerCase().split("[ :;.,!?><+*}{)('/\n]+"); for (String word : words) { //Words get formatted consistently counter = 1; diff --git a/src/TextLogik.java b/src/TextLogik.java index 38a6aea..8fd9f79 100644 --- a/src/TextLogik.java +++ b/src/TextLogik.java @@ -12,11 +12,16 @@ public class TextLogik { textOutput = new TextOutput(); String[] command; + textOutput.UserInfoOutput("######################"); + textOutput.UserInfoOutput("#WELCOME TO THE EDITOR#"); + textOutput.UserInfoOutput("######################"); do { + textOutput.UserInfoOutput("Please enter a Command: "); command = TextInput.checkForInput(); switch (command[0]) { case "ADD": + textOutput.UserInfoOutput("Please enter your text: "); if (command.length == 1) { checkIfSuccess(text.add(TextInput.getTextInput())); } else if (isNumeric(command[1])) { @@ -29,10 +34,10 @@ public class TextLogik { break; case "DEL": if (command.length == 1) { - text.del(); + checkIfSuccess(text.del()); } else if (isNumeric(command[1])) { int line = Integer.parseInt(command[1]); - text.del(line); + checkIfSuccess(text.del(line)); } else { textOutput.errorInvalidCommand(); } @@ -51,9 +56,9 @@ public class TextLogik { break; case "FORMAT": if (command.length > 1 && "RAW".equals(command[1])) { - textOutput.formatRaw(); + checkIfSuccess(textOutput.formatRaw()); } else if (command.length > 2 && "FIX".equals(command[1]) && isNumeric(command[2])) { - textOutput.formatFix(Integer.parseInt(command[2])); + checkIfSuccess(textOutput.formatFix(Integer.parseInt(command[2]))); } else { textOutput.errorInvalidCommand(); } @@ -63,11 +68,10 @@ public class TextLogik { textOutput.IndexOutput(text.index()); break; case "PRINT": - textOutput.print(text.getText()); - break; case "REPLACE": + textOutput.UserInfoOutput("Please enter your text to replace: "); if (command.length == 1){ checkIfSuccess(text.replace(TextInput.getTextInput(), TextInput.getTextInput())); }else if(isNumeric(command[1])) { @@ -98,7 +102,7 @@ public class TextLogik { private void checkIfSuccess(boolean method) { if(method) { - textOutput.UserInfoOutput("Command was successfully"); + textOutput.UserInfoOutput("Command was successfull"); }else { textOutput.errorInvalidParagraph(); } diff --git a/src/TextOutput.java b/src/TextOutput.java index c60cbbc..fe4dc90 100644 --- a/src/TextOutput.java +++ b/src/TextOutput.java @@ -103,6 +103,7 @@ public class TextOutput { } } } + System.out.println(); } }