Fixed bugs in TextLogic Commands Replace and Del

This commit is contained in:
MikeZyeman 2021-11-09 21:36:56 +01:00
parent 2bb76acb46
commit 3ce98df973
1 changed files with 8 additions and 9 deletions

View File

@ -28,11 +28,10 @@ public class TextLogik {
break;
case "DEL":
if (command.length == 1) {
text.del(TextInput.checkForInput().length);
text.del();
} else if (isNumeric(command[1])) {
int line = Integer.parseInt(command[1]);
text.del(line, text.size () - 1);
text.del(line);
} else {
textOutput.errorInvalidCommand();
}
@ -62,15 +61,15 @@ public class TextLogik {
break;
case "REPLACE":
if (command.length == 1){
text.replace(TextInput.getTextInput());
text.replace(TextInput.getTextInput(), TextInput.getTextInput());
}else if(isNumeric(command[1])) {
int line = Integer.parseInt(command[1]);
text.replace(line, text.size() - 1);
text.replace(line, TextInput.getTextInput(), TextInput.getTextInput());
}else {
textOutput.errorInvalidCommand();
}
}
break;
default:
System.out.println("Command not found. Try again");