From 9628245746f14c5b6fa3b4bc2013af8d0312ccb6 Mon Sep 17 00:00:00 2001 From: Jiaming Date: Mon, 2 Sep 2024 17:55:57 +0800 Subject: [PATCH 1/2] Improve Contacts0 class --- contacts.iml | 11 +++++++++++ src/main/java/Contacts0.java | 21 ++++++++++++++------- src/main/java/Contacts1.java | 3 +-- textui-test/runtest.bat | 0 textui-test/runtest.sh | 0 5 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 contacts.iml mode change 100644 => 100755 textui-test/runtest.bat mode change 100644 => 100755 textui-test/runtest.sh diff --git a/contacts.iml b/contacts.iml new file mode 100644 index 0000000..f76df2b --- /dev/null +++ b/contacts.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/Contacts0.java b/src/main/java/Contacts0.java index e23d58a..834682b 100644 --- a/src/main/java/Contacts0.java +++ b/src/main/java/Contacts0.java @@ -3,14 +3,13 @@ public class Contacts0 { + public static final int MAX_ENTITIES = 100; + public static final String SEPARATOR = "==================================================="; + public static void main(String[] args) { final Scanner SCANNER = new Scanner(System.in); - System.out.println("|| ==================================================="); - System.out.println("|| ==================================================="); - System.out.println("|| Contacts - Version 0.0"); - System.out.println("|| Welcome to Contacts!"); - System.out.println("|| ==================================================="); - String[][] list = new String[100][3]; + printWelcomeScreen(); + String[][] list = new String[MAX_ENTITIES][3]; int count = 0; while (true) { System.out.print("|| " + "Enter command: "); @@ -140,10 +139,18 @@ public static void main(String[] args) { + String.format("\tExample: %1$s", "help"))); break; } - for (String m : new String[]{feedback, "==================================================="}) { + for (String m : new String[]{feedback, SEPARATOR}) { System.out.println("|| " + m); } } } + private static void printWelcomeScreen() { + System.out.println("|| ==================================================="); + System.out.println("|| ==================================================="); + System.out.println("|| Contacts - Version 0.0"); + System.out.println("|| Welcome to Contacts!"); + System.out.println("|| ==================================================="); + } + } \ No newline at end of file diff --git a/src/main/java/Contacts1.java b/src/main/java/Contacts1.java index dcadc2c..2d298ab 100644 --- a/src/main/java/Contacts1.java +++ b/src/main/java/Contacts1.java @@ -7,7 +7,6 @@ **/ public class Contacts1 { - /** * Version info of the program. */ @@ -195,7 +194,7 @@ private static void exitProgram() { * @param userInputString raw input from user * @return feedback about how the command was executed */ - private static String executeCommand(String userInputString) { + private static String executeCommand(String userInputString) { final String[] commandTypeAndParams = splitCommandWordAndArgs(userInputString); final String commandType = commandTypeAndParams[0]; final String commandArgs = commandTypeAndParams[1]; diff --git a/textui-test/runtest.bat b/textui-test/runtest.bat old mode 100644 new mode 100755 diff --git a/textui-test/runtest.sh b/textui-test/runtest.sh old mode 100644 new mode 100755 From 623b8c001c1f8dc166505692e4347a0604efee89 Mon Sep 17 00:00:00 2001 From: Jiaming Date: Mon, 2 Sep 2024 17:58:24 +0800 Subject: [PATCH 2/2] Update tests --- textui-test/runtest.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/textui-test/runtest.sh b/textui-test/runtest.sh index 95bb911..3b7c74e 100755 --- a/textui-test/runtest.sh +++ b/textui-test/runtest.sh @@ -6,6 +6,7 @@ then mkdir ../bin fi + # delete output from previous run if [ -e "./ACTUAL.TXT" ] then