TextLogik sync

This commit is contained in:
Andrin Fassbind 2021-11-11 14:39:12 +01:00
parent dcf7880091
commit 2890840817
2 changed files with 10 additions and 6 deletions

View File

@ -1,4 +1,4 @@
#Äquivalenzklassen
#Equivalent
### Text.java Index method

View File

@ -1,5 +1,3 @@
import java.util.ArrayList;
public class TextLogik {
private final Text text;
private final TextOutput textOutput;
@ -19,12 +17,10 @@ public class TextLogik {
switch (command[0]) {
case "ADD":
if (command.length == 1) {
text.add(TextInput.getTextInput());
} else if (isNumeric(command[1])) {
int line = Integer.parseInt(command[1]);
text.add(line, TextInput.getTextInput());
} else {
textOutput.errorInvalidCommand();
@ -57,7 +53,7 @@ public class TextLogik {
break;
case "INDEX":
ArrayList<String> Index = text.index();
textOutput.IndexOutput(text.index());
break;
case "PRINT":
@ -94,4 +90,12 @@ public class TextLogik {
return str.matches("\\d+");
}
private void checkIfSuccess(boolean method) {
if(method) {
textOutput.UserInfoOutput("Command was successfully");
}else {
textOutput.errorInvalidParagraph();
}
}
}