diff --git a/src/main/java/Contacts0.java b/src/main/java/Contacts0.java index 212842f..94778a6 100644 --- a/src/main/java/Contacts0.java +++ b/src/main/java/Contacts0.java @@ -3,14 +3,12 @@ public class Contacts0 { + public static final int MAX_CAPACITY = 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]; + printWelcomeMessage(); + String[][] list = new String[MAX_CAPACITY][3]; int count = 0; while (true) { System.out.print("|| " + "Enter command: "); @@ -146,4 +144,12 @@ public static void main(String[] args) { } } + private static void printWelcomeMessage() { + System.out.println("|| ==================================================="); + System.out.println("|| ==================================================="); + System.out.println("|| Contacts - Version 0.0"); + System.out.println("|| Welcome to Contacts!"); + System.out.println("|| ==================================================="); + } + } diff --git a/src/main/java/Contacts1.java b/src/main/java/Contacts1.java index 4f2d805..bbc49b0 100644 --- a/src/main/java/Contacts1.java +++ b/src/main/java/Contacts1.java @@ -593,8 +593,15 @@ private static boolean isValidName(String name) { * @param phone to be validated */ private static boolean isValidPhone(String phone) { - return !phone.isEmpty(); - //TODO: implement a better validation + if (phone.isEmpty()){ + return false; + } + try { + int phoneNumber = Integer.parseInt(phone); + return (phoneNumber > 59999999 && phoneNumber < 100000000); + } catch (NumberFormatException exception) { + return false; + } } /**