From 4db62b1848c6ef3e172f30a489302246c815f533 Mon Sep 17 00:00:00 2001 From: amadoste Date: Fri, 5 Nov 2021 11:52:13 +0100 Subject: [PATCH 1/2] Added commands as cases. --- src/TextEditor.java | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/TextEditor.java b/src/TextEditor.java index a65579e..bd99b8b 100644 --- a/src/TextEditor.java +++ b/src/TextEditor.java @@ -1,3 +1,5 @@ +import java.util.ArrayList; + public class TextEditor { private SystemInput sysInput; @@ -18,14 +20,30 @@ public class TextEditor { switch (command[0]) { case "ADD": break; - case "REMOVE": + case "DEL": + break; + case "DUMMY": + text.dummy(); + break; + case "EXIT": + break; + case "FORMAT RAW": + break; + case "FORMAT FIX": + break; + case "INDEX": + ArrayList index = text.index(); + break; + case "PRINT": + break; + case "REPLACE": break; default: System.out.println("Command not found. Try again"); break; } - } while ("exit".equals(command[0])); + } while ("EXIT".equals(command[0])); } } From 62fa36bb42bbc253512f3b9cdad81a4637adffbf Mon Sep 17 00:00:00 2001 From: amadoste Date: Fri, 5 Nov 2021 12:09:22 +0100 Subject: [PATCH 2/2] Added commands as cases. --- src/TextEditor.java | 43 +------------------------------------------ src/TextLogik.java | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 44 deletions(-) diff --git a/src/TextEditor.java b/src/TextEditor.java index bd99b8b..bb87961 100644 --- a/src/TextEditor.java +++ b/src/TextEditor.java @@ -1,49 +1,8 @@ -import java.util.ArrayList; - public class TextEditor { - private SystemInput sysInput; - private Text text; public static void main(String[] args) { - TextEditor t = new TextEditor(); - } - - public TextEditor() { - sysInput = new SystemInput(); - text = new Text(); - String command[]; - - do { - command = sysInput.checkForInput(); - - switch (command[0]) { - case "ADD": - break; - case "DEL": - break; - case "DUMMY": - text.dummy(); - break; - case "EXIT": - break; - case "FORMAT RAW": - break; - case "FORMAT FIX": - break; - case "INDEX": - ArrayList index = text.index(); - break; - case "PRINT": - break; - case "REPLACE": - break; - default: - System.out.println("Command not found. Try again"); - break; - } - - } while ("EXIT".equals(command[0])); + TextLogik t = new TextLogik(); } } diff --git a/src/TextLogik.java b/src/TextLogik.java index 3064b61..bb8354d 100644 --- a/src/TextLogik.java +++ b/src/TextLogik.java @@ -1,3 +1,5 @@ +import java.util.ArrayList; + public class TextLogik { private Text text; @@ -11,14 +13,30 @@ public class TextLogik { switch (command[0]) { case "ADD": break; - case "REMOVE": + case "DEL": + break; + case "Dummy": + text.dummy(); + break; + case "EXIT": + break; + case "FORMAT RAW": + break; + case "FORMAT FIX": + break; + case "INDEX": + ArrayList Index = text.index(); + break; + case "PRINT": + break; + case "REPLACE": break; default: System.out.println("Command not found. Try again"); break; } - } while ("exit".equals(command[0])); + } while ("EXIT".equals(command[0])); } }