Skip to content

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
30 changes: 30 additions & 0 deletions .gitignore
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
34 changes: 34 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/KDTBE5_Java_Assignment3.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions me/day05/practice/practice01/AuthMethod.java
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
}
5 changes: 5 additions & 0 deletions me/day05/practice/practice01/Company.java
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
}
112 changes: 112 additions & 0 deletions me/day05/practice/practice01/Electronic.java
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; //제품일련번호

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private 사용 좋아요~ 굿

private String modelName; //전자기기 모델명

private Company companyName; //제조회사명
private String dateOfMade; //생산일자

private AuthMethod[] authMethod; //본인인증방법 , 배열로정의

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사소한 것이지만 인증 방법이 복수개니까 복수형의 느낌이 나는 authMethods로 바꿔보는 건 어떨까요~?ㅎㅎ


private static int objectNo = 0; //등록된제품순서.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static 변수는 일반 변수보다 위에 선언되는 게 좋습니다! 맨 위로 옮겨보세용~


public Electronic() {
objectNo++;
}
// 기본생성자


public Electronic( String modelName, Company companyName, String dateOfMade, AuthMethod[] authMethod) {
objectNo++;
this.productNo = LocalDate.now().format(DateTimeFormatter.ofPattern("yyMMdd")) + String.format("%04d", objectNo) ;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 좋은 아이디어네요 잘하셨어요~ 다만 String 연산에서 + 는 속도가 많이 느리다고 알려져 있어요! 지금처럼 데이터양이 크지 않고 연산이 복잡하지 않은 경우에는 +도 괜찮지만 다른 방법이 있을 거예요! 한번 공부해볼까요!

this.modelName = modelName;
this.companyName = companyName;
this.dateOfMade = dateOfMade;

Choose a reason for hiding this comment

The 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() {

Choose a reason for hiding this comment

The 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) +
'}';
}
}
15 changes: 15 additions & 0 deletions me/day05/practice/practice01/Main.java
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());
}
}
Loading