|
@@ -1,7 +1,7 @@
|
1
|
|
--
|
|
1
|
+
|
2
|
2
|
# ZCW-MicroLabs-ExceptionsAndLogging
|
3
|
3
|
|
4
|
|
--
|
|
4
|
+
|
5
|
5
|
# PhoneNumberFactory
|
6
|
6
|
* **Purpose** - to demonstrate basic exception handling and logging.
|
7
|
7
|
* **Objective** - to implement a `PhoneNumberFactory` class that generates `PhoneNumber` objects.
|
|
@@ -22,7 +22,6 @@ String phoneLineCode = phoneNumber.getPhoneLineCode();
|
22
|
22
|
```
|
23
|
23
|
|
24
|
24
|
|
25
|
|
--
|
26
|
25
|
# Part 1; Modify `createPhoneNumber`
|
27
|
26
|
* 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
|
27
|
* `InvalidPhoneNumberFormatException` extends `IOException`, which is a `checked exception`.<br>
|
|
@@ -31,7 +30,6 @@ String phoneLineCode = phoneNumber.getPhoneLineCode();
|
31
|
30
|
|
32
|
31
|
|
33
|
32
|
|
34
|
|
--
|
35
|
33
|
# Part 2; Implement `createPhoneNumberSafely`
|
36
|
34
|
* 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
|
35
|
* Use this `String` object to construct a new instance of `PhoneNumber` and return it.
|
|
@@ -39,17 +37,15 @@ String phoneLineCode = phoneNumber.getPhoneLineCode();
|
39
|
37
|
* If a `InvalidPhoneNumberFormatException` is thrown within this method, catch it and return `null`.
|
40
|
38
|
|
41
|
39
|
|
42
|
|
--
|
43
|
40
|
# Part 3; Implement `createRandomPhoneNumber`
|
44
|
41
|
* 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
|
42
|
|
46
|
|
--
|
|
43
|
+
|
47
|
44
|
# Part 4; Implement `createRandomPhoneNumberArray`
|
48
|
45
|
* Using the `createRandomPhoneNumber` from `Part 3`, generate an array of `PhoneNumber` objects, whose length reflects the input argument.
|
49
|
46
|
* For example `createRandomPhoneNumber(5)` should return an array of 5 `PhoneNumber` objects.
|
50
|
47
|
|
51
|
48
|
|
52
|
|
--
|
53
|
49
|
# Part 5; Add logging
|
54
|
50
|
* Add logging to the `createPhoneNumber` method from `Part 1`, which logs the message
|
55
|
51
|
* `"Attempting to create a new PhoneNumber object with a value of (###)-###-####`
|