Skip to content

Commit cb5dffe

Browse files
authored
한글화
1 parent 73a84d2 commit cb5dffe

1 file changed

Lines changed: 14 additions & 16 deletions

File tree

src/effectivejava/chapter3/item13/PhoneNumber.java

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
import java.util.HashMap;
44
import java.util.Map;
55

6-
// Adding a clone method to PhoneNumber (page 59)
6+
// PhoneNumber에 clone 메서드 추가 (79쪽)
77
public final class PhoneNumber implements Cloneable {
88
private final short areaCode, prefix, lineNum;
99

1010
public PhoneNumber(int areaCode, int prefix, int lineNum) {
11-
this.areaCode = rangeCheck(areaCode, 999, "area code");
12-
this.prefix = rangeCheck(prefix, 999, "prefix");
13-
this.lineNum = rangeCheck(lineNum, 9999, "line num");
11+
this.areaCode = rangeCheck(areaCode, 999, "지역코드");
12+
this.prefix = rangeCheck(prefix, 999, "프리픽스");
13+
this.lineNum = rangeCheck(lineNum, 9999, "가입자 번호");
1414
}
1515

1616
private static short rangeCheck(int val, int max, String arg) {
@@ -37,35 +37,33 @@ private static short rangeCheck(int val, int max, String arg) {
3737
}
3838

3939
/**
40-
* Returns the string representation of this phone number.
41-
* The string consists of twelve characters whose format is
42-
* "XXX-YYY-ZZZZ", where XXX is the area code, YYY is the
43-
* prefix, and ZZZZ is the line number. Each of the capital
44-
* letters represents a single decimal digit.
40+
* 이 전화번호의 문자열 표현을 반환한다.
41+
* 이 문자열은 "XXX-YYY-ZZZZ" 형태의 12글자로 구성된다.
42+
* XXX는 지역 코드, YYY는 프리픽스, ZZZZ는 가입자 번호다.
43+
* 각각의 대문자는 10진수 숫자 하나를 나타낸다.
4544
*
46-
* If any of the three parts of this phone number is too small
47-
* to fill up its field, the field is padded with leading zeros.
48-
* For example, if the value of the line number is 123, the last
49-
* four characters of the string representation will be "0123".
45+
* 전화번호의 각 부분의 값이 너무 작아서 자릿수를 채울 수 없다면,
46+
* 앞에서부터 0으로 채워나간다. 예컨대 가입자 번호가 123이라면
47+
* 전화번호의 마지막 네 문자는 "0123"이 된다.
5048
*/
5149
@Override public String toString() {
5250
return String.format("%03d-%03d-%04d",
5351
areaCode, prefix, lineNum);
5452
}
5553

56-
// Clone method for class with no references to mutable state (Page 59)
54+
// 코드 13-1 가변 상태를 참조하지 않는 클래스용 clone 메서드 (79쪽)
5755
@Override public PhoneNumber clone() {
5856
try {
5957
return (PhoneNumber) super.clone();
6058
} catch (CloneNotSupportedException e) {
61-
throw new AssertionError(); // Can't happen
59+
throw new AssertionError(); // 일어날 수 없는 일이다.
6260
}
6361
}
6462

6563
public static void main(String[] args) {
6664
PhoneNumber pn = new PhoneNumber(707, 867, 5309);
6765
Map<PhoneNumber, String> m = new HashMap<>();
68-
m.put(pn, "Jenny");
66+
m.put(pn, "제니");
6967
System.out.println(m.get(pn.clone()));
7068
}
7169
}

0 commit comments

Comments
 (0)