|
|
@@ -46,7 +46,7 @@ public final class PhoneNumberFactory {
|
|
46
|
46
|
* @return a new phone number object
|
|
47
|
47
|
*/ //TODO - if input is valid, return respective PhoneNumber object, else return null
|
|
48
|
48
|
public static PhoneNumber createPhoneNumberSafely(int areaCode, int centralOfficeCode, int phoneLineCode) {
|
|
49
|
|
- String safePhoneNumberString = String.format("(%d)-%d-%d", areaCode,centralOfficeCode,phoneLineCode);
|
|
|
49
|
+ String safePhoneNumberString = String.format("(%3d)-%3d-%4d", areaCode,centralOfficeCode,phoneLineCode);
|
|
50
|
50
|
try{
|
|
51
|
51
|
return createPhoneNumber(safePhoneNumberString);
|
|
52
|
52
|
} catch (InvalidPhoneNumberFormatException ipfe){
|
|
|
@@ -61,11 +61,7 @@ public final class PhoneNumberFactory {
|
|
61
|
61
|
* @throws InvalidPhoneNumberFormatException - thrown if phoneNumberString does not match acceptable format
|
|
62
|
62
|
*/ // TODO - Add throws statement to method signature
|
|
63
|
63
|
public static PhoneNumber createPhoneNumber(String phoneNumberString) throws InvalidPhoneNumberFormatException{
|
|
64
|
|
- String stringRepresentation = "(215)555-5555";
|
|
65
|
|
- PhoneNumber newPhoneNumber = new PhoneNumber(stringRepresentation);
|
|
66
|
|
- String areaCode = newPhoneNumber.getAreaCode();
|
|
67
|
|
- String centralOfficeCode = newPhoneNumber.getCentralOfficeCode();
|
|
68
|
|
- String phoneLineCode = newPhoneNumber.getPhoneLineCode();
|
|
|
64
|
+ PhoneNumber newPhoneNumber = new PhoneNumber(phoneNumberString);
|
|
69
|
65
|
logger.log(Level.SEVERE,"Attempting to create a phone number object with the value of newPhoneNumber");
|
|
70
|
66
|
return newPhoneNumber;
|
|
71
|
67
|
}
|