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