Khalil Malik Saboor 8 yıl önce
ebeveyn
işleme
62fab600eb

+ 7
- 2
src/main/java/com/zipcodewilmington/phone/PhoneNumberFactory.java Dosyayı Görüntüle

@@ -20,14 +20,16 @@ public final class PhoneNumberFactory {
20 20
      * @return array of randomly generated PhoneNumber objects
21 21
      */ //TODO - Implement logic
22 22
     public static PhoneNumber[] createRandomPhoneNumberArray(int phoneNumberCount) {
23
-        return null;
23
+        PhoneNumber[] phoneNumberArray = new  PhoneNumber[phoneNumberCount];
24
+        return phoneNumberArray;
24 25
     }
25 26
 
26 27
     /**
28
+     * Student[] studentArray = new Student[7];
27 29
      * @return an instance of PhoneNumber with randomly generated phone number value
28 30
      */ //TODO - Implement logic
29 31
     public static PhoneNumber createRandomPhoneNumber() {
30
-        return createPhoneNumberSafely(-1, -1, -1);
32
+        return createPhoneNumberSafely((int) Math.floor(111 + Math.random() * 111), (int) Math.floor(111 + Math.random() * 213), (int) Math.floor(1111 + Math.random() * 1111));
31 33
     }
32 34
 
33 35
 
@@ -40,9 +42,11 @@ public final class PhoneNumberFactory {
40 42
      */ //TODO - if input is valid, return respective PhoneNumber object, else return null
41 43
     public static PhoneNumber createPhoneNumberSafely(int areaCode, int centralOfficeCode, int phoneLineCode) {
42 44
         String phoneNumber = "("+ areaCode +")-"+centralOfficeCode+"-"+phoneLineCode;
45
+
43 46
         try {
44 47
             return createPhoneNumber(phoneNumber);
45 48
         } catch (InvalidPhoneNumberFormatException e) {
49
+            logger.warning("(###)-###-#### is not a valid phone number");
46 50
             e.printStackTrace();
47 51
         }
48 52
         return null;
@@ -54,6 +58,7 @@ public final class PhoneNumberFactory {
54 58
      * @throws InvalidPhoneNumberFormatException - thrown if phoneNumberString does not match acceptable format
55 59
      */ // TODO - Add throws statement to method signature
56 60
     public static PhoneNumber createPhoneNumber(String phoneNumberString) throws  InvalidPhoneNumberFormatException{
61
+            logger.warning("Attempting to create a new PhoneNumber object with a value of (###)-###-####");
57 62
         return null;
58 63
     }
59 64
 }