Added commands del and replace as cases.

This commit is contained in:
amadoste 2021-11-09 20:42:17 +01:00
parent 4c304e06e3
commit 484f745736
1 changed files with 19 additions and 1 deletions

View File

@ -27,7 +27,15 @@ public class TextLogik {
break; break;
case "DEL": case "DEL":
// TODO Hier Delete Funktion hinzufügen. if (command.length == 1){
text.del(TextInput.checkForInput().length);
}else if (isNumeric(command[1])){
int line = Integer.parseInt(command[1]);
text.del(line, text.size () - 1);
}else {
textOutput.errorInvalidCommand();
}
break; break;
case "Dummy": case "Dummy":
text.dummy(); text.dummy();
@ -53,6 +61,16 @@ public class TextLogik {
break; break;
case "REPLACE": case "REPLACE":
if (command.length == 1){
text.replace(TextInput.getTextInput());
}else if(isNumeric(command[1])) {
int line = Integer.parseInt(command[1]);
text.replace(line, text.size() - 1);
}else {
textOutput.errorInvalidCommand();
}
}
break; break;
default: default:
System.out.println("Command not found. Try again"); System.out.println("Command not found. Try again");