Merge remote-tracking branch 'origin/main'

This commit is contained in:
Leonardo Brandenberger 2021-11-11 22:11:00 +01:00
commit 42bd8eeadc
2 changed files with 9 additions and 11 deletions

View File

@ -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;
}

View File

@ -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();
}