From 3ce98df97351214f3f1df900b1cc988487de39cb Mon Sep 17 00:00:00 2001 From: MikeZyeman Date: Tue, 9 Nov 2021 21:36:56 +0100 Subject: [PATCH] Fixed bugs in TextLogic Commands Replace and Del --- src/TextLogik.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/TextLogik.java b/src/TextLogik.java index 3d6ab4f..ab0126e 100644 --- a/src/TextLogik.java +++ b/src/TextLogik.java @@ -27,13 +27,12 @@ public class TextLogik { break; case "DEL": - if (command.length == 1){ - text.del(TextInput.checkForInput().length); - }else if (isNumeric(command[1])){ + if (command.length == 1) { + text.del(); + } else if (isNumeric(command[1])) { int line = Integer.parseInt(command[1]); - - text.del(line, text.size () - 1); - }else { + text.del(line); + } else { textOutput.errorInvalidCommand(); } break; @@ -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");