Skip to content

Commit ad9d25a

Browse files
committed
refactor: 코드리뷰 반영(Electronic)
메서드 이름 변경 isContainAuthMethod -> isContainsAuthMethod (최대한 문법을 지키도록 노력하자) 생성자의 접근 제어자 변경 (익숙한 것에서 실수가 나온다.. 조심하자) resetRegistrationNo() 메서드 삭제 (가독성과 코드 집중화를 고려해보자)
1 parent b532bf1 commit ad9d25a

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

me/day05/practice/Electronic.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ enum AuthMethod { FINGERPRINT, PIN, PATTERN, FACE }
2020
private String dateOfMade;
2121
private AuthMethod[] authMethod;
2222

23-
Electronic () {
23+
private Electronic () {
2424
registrationNo++;
2525
setDateOfMade();
2626
setProductNo();
@@ -39,15 +39,11 @@ private void setDateOfMade(){
3939
}
4040

4141
private void setProductNo(){
42-
if (registrationNo > MAX_REGISTRATION_NUMBER) resetRegistrationNo();
42+
if (registrationNo > MAX_REGISTRATION_NUMBER) registrationNo = 1;
4343
productNo = dateOfMade + String.format("%4d", registrationNo).replace(" ", "0");
4444
}
4545

46-
private void resetRegistrationNo(){
47-
registrationNo = 1;
48-
}
49-
50-
public boolean isContainAuthMethod(AuthMethod authMethod){
46+
public boolean isContainsAuthMethod(AuthMethod authMethod){
5147
for (AuthMethod auth : this.authMethod)
5248
if (authMethod.equals(auth)) return true;
5349
return false;

me/day05/practice/Electronics.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public Optional<Electronic[]> groupByAuthMethod(AuthMethod authMethod){
6363
List<Electronic> temp = new ArrayList<>();
6464

6565
for (Electronic electronic : electronicList)
66-
if (electronic.isContainAuthMethod(authMethod))
66+
if (electronic.isContainsAuthMethod(authMethod))
6767
temp.add(electronic);
6868

6969
Electronic[] authMethodNameGroup =

0 commit comments

Comments
 (0)