From 1e0aced0d7f87cc64f21adaf27ca549f2498fb02 Mon Sep 17 00:00:00 2001 From: ChunJia Date: Fri, 30 Aug 2024 17:52:10 +0800 Subject: [PATCH 1/2] Improve Contacts0 class --- src/main/java/Contacts0.java | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/java/Contacts0.java b/src/main/java/Contacts0.java index e23d58a..4ee0b59 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: "); @@ -19,6 +18,7 @@ public static void main(String[] args) { inputLine = SCANNER.nextLine(); } String userCommand = inputLine; + System.out.println("|| [Command entered:" + userCommand + "]"); String feedback; final String[] split = userCommand.trim().split("\\s+", 2); @@ -140,10 +140,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 From 09f0cb48aec412c6a8fea25d5887b89bd11706c7 Mon Sep 17 00:00:00 2001 From: ChunJia Date: Fri, 30 Aug 2024 17:55:15 +0800 Subject: [PATCH 2/2] Update tests --- textui-test/EXPECTED.TXT | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/textui-test/EXPECTED.TXT b/textui-test/EXPECTED.TXT index 047bf26..7e9849d 100644 --- a/textui-test/EXPECTED.TXT +++ b/textui-test/EXPECTED.TXT @@ -1,6 +1,6 @@ || =================================================== || =================================================== -|| Contacts - Version 0.0 +|| Contacts - Version 1.0 || Welcome to Contacts! || =================================================== || Enter command: || [Command entered:help]