-
Notifications
You must be signed in to change notification settings - Fork 0
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
Java Assignment3 upload by JunHoMun #34
base: main
Are you sure you want to change the base?
Changes from all commits
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,29 @@ | ||
### IntelliJ IDEA ### | ||
out/ | ||
!**/src/main/**/out/ | ||
!**/src/test/**/out/ | ||
|
||
### Eclipse ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
bin/ | ||
!**/src/main/**/bin/ | ||
!**/src/test/**/bin/ | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Mac OS ### | ||
.DS_Store |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="jdk" jdkName="17" jdkType="JavaSDK" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,122 @@ | ||||||
package me.day05.practice.Practice01; | ||||||
|
||||||
|
||||||
import java.time.LocalDate; | ||||||
import java.time.LocalDateTime; | ||||||
import java.time.ZoneId; | ||||||
import java.util.Arrays; | ||||||
import java.util.Objects; | ||||||
|
||||||
public class Electronic { | ||||||
|
||||||
public enum companyName {SAMSUNG,LG,APPLE} | ||||||
public enum authMethod {FINGERPRINT, PATTERN, PIN, FACE} | ||||||
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.
Suggested change
|
||||||
private authMethod[] authMethods; | ||||||
private companyName company; | ||||||
private String productNo; | ||||||
private static int productionCount=1; | ||||||
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.
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.
Suggested change
사소한거지만 코드 스타일도 맞춰주시면 좋을 것 같아요!! 인텔리제이의 자동정렬 기능을 활용해보시죠~ |
||||||
|
||||||
private String modelName; | ||||||
private LocalDateTime dateOfMade; | ||||||
|
||||||
public Electronic(companyName companyName, authMethod []authMehods, String modelName){ | ||||||
|
||||||
StringBuffer generateProductNo; | ||||||
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. 제품 일련번호를 생성하는 함수를 |
||||||
generateProductNo = new StringBuffer(LocalDate.now().getYear()%100); | ||||||
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.
위에서 미리 꺼내놓는다면 불필요한 함수 콜을 줄일 수 있을 것 같습니다! |
||||||
generateProductNo.append(String.format("%02",LocalDate.now().getDayOfMonth())); | ||||||
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. 월이니까 |
||||||
generateProductNo.append(String.format("%02",LocalDate.now().getDayOfMonth())); | ||||||
generateProductNo.append(String.format("%04",productionCount++ )); | ||||||
this.productNo = String.valueOf(getProductNo()); | ||||||
this.authMethods = authMehods; | ||||||
this.company = companyName; | ||||||
this.modelName = modelName; | ||||||
this.dateOfMade = LocalDateTime.now(ZoneId.systemDefault()); | ||||||
|
||||||
} | ||||||
|
||||||
public authMethod[] getAuthMethods() { | ||||||
return authMethods; | ||||||
} | ||||||
|
||||||
public void setAuthMethods(authMethod[] authMethods) { | ||||||
this.authMethods = authMethods; | ||||||
} | ||||||
|
||||||
public companyName getCompany() { | ||||||
return company; | ||||||
} | ||||||
|
||||||
public void setCompany(companyName company) { | ||||||
this.company = company; | ||||||
} | ||||||
|
||||||
public String getProductNo() { | ||||||
return productNo; | ||||||
} | ||||||
|
||||||
public void setProductNo(String productNo) { | ||||||
this.productNo = productNo; | ||||||
} | ||||||
|
||||||
public static int getProductionCount() { | ||||||
return productionCount; | ||||||
} | ||||||
|
||||||
public static void setProductionCount(int productionCount) { | ||||||
Electronic.productionCount = productionCount; | ||||||
} | ||||||
|
||||||
public LocalDateTime getDateOfMade() { | ||||||
return dateOfMade; | ||||||
} | ||||||
|
||||||
public void setDateOfMade(LocalDateTime dateOfMade) { | ||||||
this.dateOfMade = dateOfMade; | ||||||
} | ||||||
|
||||||
public String getModelName() { | ||||||
return modelName; | ||||||
} | ||||||
|
||||||
public void setModelName(String modelName) { | ||||||
this.modelName = modelName; | ||||||
} | ||||||
|
||||||
@Override | ||||||
public boolean equals(Object o) { | ||||||
if (this == o) return true; | ||||||
if (o == null || getClass() != o.getClass()) return false; | ||||||
|
||||||
Electronic that = (Electronic) o; | ||||||
|
||||||
if (!Objects.equals(productNo, that.productNo)) return false; | ||||||
if (!Objects.equals(dateOfMade, that.dateOfMade)) return false; | ||||||
if (!Objects.equals(modelName, that.modelName)) return false; | ||||||
if (company != that.company) return false; | ||||||
// Probably incorrect - comparing Object[] arrays with Arrays.equals | ||||||
return Arrays.equals(authMethods, that.authMethods); | ||||||
} | ||||||
|
||||||
@Override | ||||||
public int hashCode() { | ||||||
int result = productNo != null ? productNo.hashCode() : 0; | ||||||
result = 31 * result + (dateOfMade != null ? dateOfMade.hashCode() : 0); | ||||||
result = 31 * result + (modelName != null ? modelName.hashCode() : 0); | ||||||
result = 31 * result + (company != null ? company.hashCode() : 0); | ||||||
result = 31 * result + Arrays.hashCode(authMethods); | ||||||
return result; | ||||||
} | ||||||
|
||||||
|
||||||
@Override | ||||||
public String toString() { | ||||||
return "Electronic{" + | ||||||
"productNo=" + productNo + | ||||||
", dateOfMade=" + dateOfMade + | ||||||
", modelName='" + modelName + '\'' + | ||||||
", company=" + company + | ||||||
", authMethods=" + Arrays.toString(authMethods) + | ||||||
'}'; | ||||||
} | ||||||
|
||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package me.day05.practice.Practice01; | ||
|
||
import java.util.Arrays; | ||
import java.util.Objects; | ||
|
||
public class User { | ||
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. 요구사항을 꼼꼼히 확인해주시면 좋을 것 같네요~😀
|
||
|
||
private String userId; | ||
private String userPassword; | ||
private int userPhoneNumber; | ||
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. 휴대폰 번호를 담는 변수형이 |
||
private String userEmail; | ||
private int userBirthDate; | ||
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. 생년월일이 |
||
private Electronic[] electronicDevices; | ||
|
||
|
||
public User(){}// default 생성자 | ||
|
||
public User(String userId){ | ||
this.userId = userId; | ||
} | ||
|
||
public User(String userId, String userPassword, int userPhoneNumber, String userEmail, int userBirthDate, Electronic[] electronicDevices) { | ||
this.userId = userId; | ||
this.userPassword = userPassword; | ||
this.userPhoneNumber = userPhoneNumber; | ||
this.userEmail = userEmail; | ||
this.userBirthDate = userBirthDate; | ||
this.electronicDevices = electronicDevices; | ||
} | ||
|
||
public String getUserId() { | ||
return userId; | ||
} | ||
|
||
public void setUserId(String userId) { | ||
this.userId = userId; | ||
} | ||
|
||
public String getUserPassword() { | ||
return userPassword; | ||
} | ||
|
||
public void setUserPassword(String userPassword) { | ||
this.userPassword = userPassword; | ||
} | ||
|
||
public int getUserPhoneNumber() { | ||
return userPhoneNumber; | ||
} | ||
|
||
public void setUserPhoneNumber(int userPhoneNumber) { | ||
this.userPhoneNumber = userPhoneNumber; | ||
} | ||
|
||
public String getUserEmail() { | ||
return userEmail; | ||
} | ||
|
||
public void setUserEmail(String userEmail) { | ||
this.userEmail = userEmail; | ||
} | ||
|
||
public int getUserBirthDate() { | ||
return userBirthDate; | ||
} | ||
|
||
public void setUserBirthDate(int userBirthDate) { | ||
this.userBirthDate = userBirthDate; | ||
} | ||
|
||
public Electronic[] getElectronicDevices() { | ||
return electronicDevices; | ||
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. 여기서 문제! 이렇게 반환된 배열을 외부에서 수정하면 원본 배열에 영향이 있을까요 없을까요? |
||
} | ||
|
||
public void setElectronicDevices(Electronic[] electronicDevices) { | ||
this.electronicDevices = electronicDevices; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
User user = (User) o; | ||
|
||
return Objects.equals(userId, user.userId); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return userId.hashCode(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "User{" + | ||
"userId='" + userId + '\'' + | ||
", userPassword='" + userPassword + '\'' + | ||
", userPhoneNumber=" + userPhoneNumber + | ||
", userEmail='" + userEmail + '\'' + | ||
", userBirthDate=" + userBirthDate + | ||
", electronicDevices=" + Arrays.toString(electronicDevices) + | ||
'}'; | ||
} | ||
} |
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.
Enum
도 별도의 클래스로 분리시켜주시면 좋을 것 같습니다~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.