-
Notifications
You must be signed in to change notification settings - Fork 3
MobilePhoneNoFeatureEnvy test
Mikhail Pravilov edited this page Jul 3, 2018
·
1 revision
This code has no smells. It is correction of MobilePhoneWithFeatureEnvy test case.
Member | Move to |
---|---|
- | - |
package mobilePhoneNoFeatureEnvy;
public class Customer {
private Phone mobilePhone;
public String getMobilePhoneNumber() {
return mobilePhone.toFormattedString();
}
}
package mobilePhoneNoFeatureEnvy;
public class Phone {
private final String unformattedNumber;
public Phone(String unformattedNumber) {
this.unformattedNumber = unformattedNumber;
}
private String getAreaCode() {
return unformattedNumber.substring(0, 3);
}
private String getPrefix() {
return unformattedNumber.substring(3, 6);
}
private String getNumber() {
return unformattedNumber.substring(6, 10);
}
public String toFormattedString() {
return "(" + getAreaCode() + ") " + getPrefix() + "-" + getNumber();
}
}