From c7faf176b880794355d23336e8cbb244725345fd Mon Sep 17 00:00:00 2001 From: ivan-tan Date: Sun, 2 Feb 2025 23:39:22 +0800 Subject: [PATCH 1/2] Update Contact0 by refactoring Defined MAX_ENTRIES, MAX_FIELDS and LINE_SEPERATOR --- 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..1f797f8 100644 --- a/src/main/java/Contacts0.java +++ b/src/main/java/Contacts0.java @@ -3,14 +3,14 @@ public class Contacts0 { + public static final int MAX_ENTRIES = 100; + public static final int MAX_FIELDS = 3; + public static final String LINE_SEPERATOR = "==================================================="; + 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]; + printWelcomeMsg(); + String[][] list = new String[MAX_ENTRIES][MAX_FIELDS]; int count = 0; while (true) { System.out.print("|| " + "Enter command: "); @@ -113,7 +113,7 @@ public static void main(String[] args) { break; case "exit": for (String m1 : new String[]{"Exiting Contacts... Good bye!", - "===================================================", + LINE_SEPERATOR, "==================================================="}) { System.out.println("|| " + m1); } @@ -146,4 +146,12 @@ public static void main(String[] args) { } } + private static void printWelcomeMsg() { + 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 041578370f920ffac8bcd0a7306f0a044b05ab7e Mon Sep 17 00:00:00 2001 From: ivan-tan Date: Sun, 2 Feb 2025 23:40:30 +0800 Subject: [PATCH 2/2] Update test Changed expected version from 0.0 to 1.0 --- 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]