-
Notifications
You must be signed in to change notification settings - Fork 0
Java Assignment3 upload by WooSeokLee #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
8b68783
1de6550
0209777
33f9948
379895a
48ef167
1ca39db
cdad27b
6eaa189
ace625c
90859e5
0e945f8
e248a49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Created by https://www.toptal.com/developers/gitignore/api/java | ||
# Edit at https://www.toptal.com/developers/gitignore?templates=java | ||
|
||
### Java ### | ||
# Compiled class file | ||
*.class | ||
|
||
# Log file | ||
*.log | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.nar | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
replay_pid* | ||
|
||
# End of https://www.toptal.com/developers/gitignore/api/java |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package me.day05.practice.practice01; | ||
|
||
public enum AuthMethod { | ||
FINGERPRINT, PATTERN, PIN, FACE | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package me.day05.practice.practice01; | ||
|
||
public enum Company { | ||
SAMSUNG, LG, APPLE | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package me.day05.practice.practice01; | ||
|
||
import java.time.LocalDate; | ||
import java.time.format.DateTimeFormatter; | ||
import java.util.Arrays; | ||
import java.util.Objects; | ||
|
||
public class Electronic { | ||
|
||
private String productNo; //제품일련번호 | ||
private String modelName; //전자기기 모델명 | ||
|
||
private Company companyName; //제조회사명 | ||
private String dateOfMade; //생산일자 | ||
|
||
private AuthMethod[] authMethod; //본인인증방법 , 배열로정의 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 사소한 것이지만 인증 방법이 복수개니까 복수형의 느낌이 나는 authMethods로 바꿔보는 건 어떨까요~?ㅎㅎ |
||
|
||
private static int objectNo = 0; //등록된제품순서. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. static 변수는 일반 변수보다 위에 선언되는 게 좋습니다! 맨 위로 옮겨보세용~ |
||
|
||
public Electronic() { | ||
WooSeok77 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
objectNo++; | ||
} | ||
// 기본생성자 | ||
|
||
|
||
public Electronic( String modelName, Company companyName, String dateOfMade, AuthMethod[] authMethod) { | ||
objectNo++; | ||
this.productNo = LocalDate.now().format(DateTimeFormatter.ofPattern("yyMMdd")) + String.format("%04d", objectNo) ; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오 좋은 아이디어네요 잘하셨어요~ 다만 String 연산에서 + 는 속도가 많이 느리다고 알려져 있어요! 지금처럼 데이터양이 크지 않고 연산이 복잡하지 않은 경우에는 +도 괜찮지만 다른 방법이 있을 거예요! 한번 공부해볼까요! |
||
this.modelName = modelName; | ||
this.companyName = companyName; | ||
this.dateOfMade = dateOfMade; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 생산일자가 원하는 값으로 들어오지 않을 수 있으니, 유효성 검증 이후에 값을 매핑해주는 게 좋을 것 같아요. 유효성 검증에서 어긋나면 기본적으로 매핑해줄 값을 넣어주는 것도 방법이겠죠?ㅎㅎ |
||
this.authMethod = authMethod; | ||
|
||
|
||
} | ||
//5개의 인자를 가지는 생성자 | ||
|
||
|
||
public String getProductNo() { | ||
return productNo; | ||
} | ||
|
||
public void setProductNo(String productNo) { | ||
this.productNo = productNo; | ||
} | ||
|
||
public String getModelName() { | ||
return modelName; | ||
} | ||
|
||
public void setModelName(String modelName) { | ||
this.modelName = modelName; | ||
} | ||
|
||
public Company getCompanyName() { | ||
return companyName; | ||
} | ||
|
||
public void setCompanyName(Company companyName) { | ||
this.companyName = companyName; | ||
} | ||
|
||
public String getDateOfMade() { | ||
return dateOfMade; | ||
} | ||
|
||
public void setDateOfMade(String dateOfMade) { | ||
this.dateOfMade = dateOfMade; | ||
} | ||
|
||
public AuthMethod[] getAuthMethod() { | ||
return authMethod; | ||
} | ||
|
||
public void setAuthMethod(AuthMethod[] authMethod) { | ||
this.authMethod = authMethod; | ||
} | ||
|
||
public static int getObjectNo() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 경우에도 다른 메소드보다 위에 위치하는 게 좋을 것 같아요~ 위로 고고 |
||
return objectNo; | ||
} | ||
|
||
public static void setObjectNo(int objectNo) { | ||
Electronic.objectNo = objectNo; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
Electronic that = (Electronic) o; | ||
return Objects.equals(productNo, that.productNo) && Objects.equals(modelName, that.modelName) && companyName == that.companyName && Objects.equals(dateOfMade, that.dateOfMade) && Arrays.equals(authMethod, that.authMethod); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = Objects.hash(productNo, modelName, companyName, dateOfMade); | ||
result = 31 * result + Arrays.hashCode(authMethod); | ||
return result; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "{" + | ||
"productNo='" + productNo + '\'' + | ||
", modelName='" + modelName + '\'' + | ||
", companyName=" + companyName + | ||
", dateOfMade='" + dateOfMade + '\'' + | ||
", authMethod=" + Arrays.toString(authMethod) + | ||
'}'; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package me.day05.practice.practice01; | ||
|
||
|
||
|
||
public class Main { | ||
public static void main(String[] args) { | ||
Electronic a1 = new Electronic("javis", Company.SAMSUNG, "20000120", new AuthMethod[]{AuthMethod.PIN}); | ||
System.out.println(a1.toString()); | ||
Electronic a2 = new Electronic("havis", Company.SAMSUNG, "20000121", new AuthMethod[]{AuthMethod.PIN}); | ||
System.out.println(a2.toString()); | ||
|
||
User m1 = new User("fallen", "page7", "010-2222-3333", "[email protected]", "060220", new String[]{"hell"}); | ||
System.out.println(m1.toString()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private 사용 좋아요~ 굿