From 484f745736b599e7687168c62536c67eec684609 Mon Sep 17 00:00:00 2001 From: amadoste Date: Tue, 9 Nov 2021 20:42:17 +0100 Subject: [PATCH 1/2] Added commands del and replace as cases. --- src/TextLogik.java | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/TextLogik.java b/src/TextLogik.java index aea3198..3d6ab4f 100644 --- a/src/TextLogik.java +++ b/src/TextLogik.java @@ -27,7 +27,15 @@ public class TextLogik { break; 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; case "Dummy": text.dummy(); @@ -53,6 +61,16 @@ public class TextLogik { break; 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; default: System.out.println("Command not found. Try again"); From da64e520713691576fec35745518ca04122e1fdc Mon Sep 17 00:00:00 2001 From: schrom01 Date: Tue, 9 Nov 2021 20:48:18 +0100 Subject: [PATCH 2/2] added testmethod add in TextText Class --- .idea/runConfigurations.xml | 10 ++++++++++ docs/README.md => README.md | 0 2 files changed, 10 insertions(+) create mode 100644 .idea/runConfigurations.xml rename docs/README.md => README.md (100%) diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..797acea --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/docs/README.md b/README.md similarity index 100% rename from docs/README.md rename to README.md