Created
October 11, 2019 07:48
-
-
Save djiwandou/8f78bd2cc5cf52359cb146bf8936fd29 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Phone { | |
| private final String unformattedNumber; | |
| public Phone(String unformattedNumber) { | |
| this.unformattedNumber = unformattedNumber; | |
| } | |
| public String getAreaCode() { | |
| return unformattedNumber.substring(0,3); | |
| } | |
| public String getPrefix() { | |
| return unformattedNumber.substring(3,6); | |
| } | |
| public String getNumber() { | |
| return unformattedNumber.substring(6,10); | |
| } | |
| } | |
| public class Customer { | |
| private Phone mobilePhone; | |
| public String getMobilePhoneNumber() { | |
| return "(" + | |
| mobilePhone.getAreaCode() + ") " + | |
| mobilePhone.getPrefix() + "-" + | |
| mobilePhone.getNumber(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment