TextLogik sync
This commit is contained in:
+9
-5
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user