Skip to content
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

Assignment of Day05 Uploaded By JongYoonBae #28

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 3 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@
<br/>

### 자바 과제3 <br/><br/>
> 제출자 - 최은빈
> 제출자 - 배종윤
> 출시일 - 23.04.11.
> 제출일 - 23.04.17.

- [Day5](https://echoiing-fastcampus.notion.site/3-49385516d4e7430da0bfb85012f22cd9) 문제를 풀어서 제출하시오.

- 파일 이름 작성법
- ````me.day05.practice```` 패키지 생성
- ````Practice01, Practice02, Practice03, ...```` 클래스 생성하여 작성
- 제출방법
- 본인의 이름으로 ````branch````를 생성하여 ````push````후 ````pull request```` 작성
- 예시
- branch 이름 - ````FirstNameLastName````
- commit 메시지 - ````Java Assignment3 upload by FirstNameLastName````
- pull request는 본인이 하고 싶은 말이나 질문을 적어주세요.
- ````코드리뷰 빡세게 부탁드립니다.```` ````클린한 코드인지 봐주세요.```` ````이 코드의 조금 더 나은 방법이 있을까요.````
- ````~~번 문제 풀지 못했습니다.```` ````~~번 문제 풀이 방법을 알려주시면 감사하겠습니다.````
- ````결과는 나왔는데 맞는지 모르겠습니다.````
- 주의사항
- 본인 ```branch``` -> ```main branch``` PR한 상태로 제출부탁드립니다.
- ```main branch```에 본인 ```branch```의 ```commit```을 ```merge``` 하지 마시기 바랍니다.

- branch name : JongYoonBae
- Test File : Test.java
<br/>
25 changes: 25 additions & 0 deletions src/me/day05/practice/AuthMethod.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package me.day05.practice;

enum AuthMethod {
FINGER_PRINT("Finger Print"),
PATTERN("Pattern"),
PIN("PIN"),
FACE("Face"),
FOOT("Foot");

private final String authType;

AuthMethod(String authType) {
this.authType = authType;
}

public String getAuthType() {
return authType;
}

//useless in this time
/*public static boolean isValidAuthType(List<AuthMethod> authMethod){
return Arrays.stream(AuthMethod.values())
.anyMatch(authType -> authMethod.contains(authType));
}*/
}
22 changes: 22 additions & 0 deletions src/me/day05/practice/Company.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package me.day05.practice;

enum Company {
LG("LG"),
SAMSUNG("SAMSUNG"),
APPLE("APPLE"),
GOOGLE("GOOGLE");
private final String companyName;
Company(String companyName) {
this.companyName = companyName;
}

public String getCompanyName() {
return companyName;
}

//useless in this time
/*public static boolean isValidCompany(Company company){
return Arrays.asList(Company.values()).stream()
.anyMatch(companyName -> companyName == company);
}*/
}
5 changes: 5 additions & 0 deletions src/me/day05/practice/Define.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package me.day05.practice;

public class Define {
public static final int DEFAULT_CAPACITY = 20;
}
147 changes: 147 additions & 0 deletions src/me/day05/practice/Electronic.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
package me.day05.practice;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Objects;

public class Electronic {
private String productNo;
private static int productId;
private String modelName;
private String companyName;
private LocalDate dateOfMade;
private List<AuthMethod> authMethod;

Electronic(Builder builder){
modelName = builder.modelName;
companyName = builder.companyName;
dateOfMade = builder.dateOfMade;
productNo = this.dateOfMade.format(DateTimeFormatter.ofPattern("yyMMdd"))+String.format("%04d",productId+1);
authMethod = builder.authMethod;
//init productId > 9998
if (productId > 9998) {
productId = 0;
} else {
productId++;
}
}

/*
assignment 1
getter(), setter(), hashcode(), equals(), toString()
*/
//add conditions in getter & setter if necessary

public String getProductNo() {
return productNo;
}

public void setProductNo(String productNo) {
this.productNo = productNo;
}

public static int getProductId() {
return productId;
}

public static void setProductId(int productId) {
Electronic.productId = productId;
}

public String getModelName() {
return modelName;
}

public void setModelName(String modelName) {
this.modelName = modelName;
}

public String getCompanyName() {
return companyName;
}

public void setCompanyName(String companyName) {
this.companyName = companyName;
}

public LocalDate getDateOfMade() {
return dateOfMade;
}

public void setDateOfMade(LocalDate dateOfMade) {
this.dateOfMade = dateOfMade;
}

public List<AuthMethod> getAuthMethod() {
return authMethod;
}

public void setAuthMethod(List<AuthMethod> authMethod) {
this.authMethod = authMethod;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Electronic that)) return false;
return productNo.equals(that.productNo) && modelName.equals(that.modelName) && companyName.equals(that.companyName) && dateOfMade.equals(that.dateOfMade) && authMethod.equals(that.authMethod);
}

@Override
public int hashCode() {
return Objects.hash(productNo, modelName, companyName, dateOfMade, authMethod);
}

@Override
public String toString() {
return "Electronic{" +
"productNo='" + productNo + '\'' +
", modelName='" + modelName + '\'' +
", companyName='" + companyName + '\'' +
", dateOfMade=" + dateOfMade +
", authMethod=" + authMethod +
'}'+"\n";
}

public static class Builder{
private String modelName;
private String companyName;
private LocalDate dateOfMade;
private List<AuthMethod> authMethod;

public Builder modelName (String modelName) {
this.modelName = modelName;
return this;
}

public Builder companyName (String companyName){
this.companyName = companyName;
return this;
}

public Builder dateOfMade (LocalDate dateOfMade){
this.dateOfMade = dateOfMade;
return this;
}

public Builder authMethod (List<AuthMethod> authMethod){
this.authMethod = authMethod;
return this;
}

public Electronic build() {
return new Electronic(this);
}

@Override
public String toString() {
return "Builder{" +
"modelName='" + modelName + '\'' +
", companyName='" + companyName + '\'' +
", dateOfMade=" + dateOfMade +
", authMethod=" + authMethod +
'}';
}
}
}
Loading