|
@@ -1,8 +1,8 @@
|
1
|
1
|
-
|
2
|
|
-#ZCW-MicroLabs-ExceptionsAndLogging
|
|
2
|
+# ZCW-MicroLabs-ExceptionsAndLogging
|
3
|
3
|
|
4
|
4
|
-
|
5
|
|
-#PhoneNumberFactory
|
|
5
|
+# PhoneNumberFactory
|
6
|
6
|
* **Purpose** - to demonstrate basic exception handling and logging.
|
7
|
7
|
* **Objective** - to implement a `PhoneNumberFactory` class that generates `PhoneNumber` objects.
|
8
|
8
|
* The `PhoneNumber` class is a container for a `String` representation of a respective phone number.
|
|
@@ -23,7 +23,7 @@ String phoneLineCode = phoneNumber.getPhoneLineCode();
|
23
|
23
|
|
24
|
24
|
|
25
|
25
|
-
|
26
|
|
-#Part 1; Modify `createPhoneNumber`
|
|
26
|
+# Part 1; Modify `createPhoneNumber`
|
27
|
27
|
* Upon instantiating a new `PhoneNumber` object, it is possible to receive a `InvalidPhoneNumberFormatException` if the `String` passed into the `PhoneNumber` constructor does not fit the format `(###)-###-####`.<br>
|
28
|
28
|
* `InvalidPhoneNumberFormatException` extends `IOException`, which is a `checked exception`.<br>
|
29
|
29
|
* Modify the `createPhoneNumber` method so that it throws any resulting `InvalidPhoneNumberFormatException`.
|
|
@@ -32,7 +32,7 @@ String phoneLineCode = phoneNumber.getPhoneLineCode();
|
32
|
32
|
|
33
|
33
|
|
34
|
34
|
-
|
35
|
|
-#Part 2; Implement `createPhoneNumberSafely`
|
|
35
|
+# Part 2; Implement `createPhoneNumberSafely`
|
36
|
36
|
* Using the `createPhoneNumber` method from `Part 1`, define the `createPhoneNumberSafely` method such that the input parameters, `areaCode`, `centralOfficeCode`, `phoneLineCode` are concatenated to create a `String` representation of the respective phone number.
|
37
|
37
|
* Use this `String` object to construct a new instance of `PhoneNumber` and return it.
|
38
|
38
|
* If the concatentation of the input parameters yields a `String` whose value does not match the format `(###)-###-####`, then our `PhoneNumber` will throw a `InvalidPhoneNumberFormatException`.
|
|
@@ -40,17 +40,17 @@ String phoneLineCode = phoneNumber.getPhoneLineCode();
|
40
|
40
|
|
41
|
41
|
|
42
|
42
|
-
|
43
|
|
-#Part 3; Implement `createRandomPhoneNumber`
|
|
43
|
+# Part 3; Implement `createRandomPhoneNumber`
|
44
|
44
|
* Using the `RandomNumberFactory`, generate a random `Area Code`, `Central Office Code`, and `Phone Line Code`. Pass these values as arguments of the `createPhoneNumberSafely` method from `Part 2` and return the resulting `PhoneNumber` object.
|
45
|
45
|
|
46
|
46
|
-
|
47
|
|
-#Part 4; Implement `createRandomPhoneNumberArray`
|
|
47
|
+# Part 4; Implement `createRandomPhoneNumberArray`
|
48
|
48
|
* Using the `createRandomPhoneNumber` from `Part 3`, generate an array of `PhoneNumber` objects, whose length reflects the input argument.
|
49
|
49
|
* For example `createRandomPhoneNumber(5)` should return an array of 5 `PhoneNumber` objects.
|
50
|
50
|
|
51
|
51
|
|
52
|
52
|
-
|
53
|
|
-#Part 5; Add logging
|
|
53
|
+# Part 5; Add logging
|
54
|
54
|
* Add logging to the `createPhoneNumber` method from `Part 1`, which logs the message
|
55
|
55
|
* `"Attempting to create a new PhoneNumber object with a value of (###)-###-####`
|
56
|
56
|
* where `(###)-###-####` will be replaced with the respective input parameter.
|
|
@@ -60,5 +60,5 @@ String phoneLineCode = phoneNumber.getPhoneLineCode();
|
60
|
60
|
* Where `(###)-###-####` will be replaced with the respective input parameter.
|
61
|
61
|
|
62
|
62
|
|
63
|
|
-#Part 6; Ensure all test cases pass
|
|
63
|
+# Part 6; Ensure all test cases pass
|
64
|
64
|
* Yeah this header says all that is needed...
|