From c11d761de3ba729afe7ecfabdf968617a65db8b2 Mon Sep 17 00:00:00 2001 From: johanesrafael Date: Fri, 4 Sep 2020 20:01:04 +0800 Subject: [PATCH 1/2] refactor a method in Contacts0.java --- src/main/java/Contacts0.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/java/Contacts0.java b/src/main/java/Contacts0.java index 212842f..df63752 100644 --- a/src/main/java/Contacts0.java +++ b/src/main/java/Contacts0.java @@ -2,15 +2,12 @@ public class Contacts0 { + public static final int MAX_CONTACT = 100; 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]; + showWelcomeMessage(); + String[][] list = new String[MAX_CONTACT][3]; int count = 0; while (true) { System.out.print("|| " + "Enter command: "); @@ -92,7 +89,7 @@ public static void main(String[] args) { feedback = String.format("%1$d persons found!", count); break; case "clear": - list = new String[100][3]; + list = new String[MAX_CONTACT][3]; count = 0; feedback = "Contacts have been cleared!"; break; @@ -146,4 +143,12 @@ public static void main(String[] args) { } } + private static void showWelcomeMessage() { + System.out.println("|| ==================================================="); + System.out.println("|| ==================================================="); + System.out.println("|| Contacts - Version 0.0"); + System.out.println("|| Welcome to Contacts!"); + System.out.println("|| ==================================================="); + } + } From f11d35e20c5b73c899f102ddd79f8ce776556b17 Mon Sep 17 00:00:00 2001 From: johanesrafael Date: Fri, 4 Sep 2020 20:05:06 +0800 Subject: [PATCH 2/2] Refactor a method in Contacts0.java --- src/main/java/Contacts0.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/Contacts0.java b/src/main/java/Contacts0.java index df63752..8262f22 100644 --- a/src/main/java/Contacts0.java +++ b/src/main/java/Contacts0.java @@ -7,6 +7,7 @@ public class Contacts0 { public static void main(String[] args) { final Scanner SCANNER = new Scanner(System.in); showWelcomeMessage(); + String[][] list = new String[MAX_CONTACT][3]; int count = 0; while (true) {