Skip to content
Open
8 changes: 8 additions & 0 deletions .idea/.gitignore

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

9 changes: 9 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.

7 changes: 7 additions & 0 deletions .idea/discord.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/misc.xml

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

9 changes: 9 additions & 0 deletions .idea/modules.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.

11 changes: 11 additions & 0 deletions day05assignment/day05assignment.iml
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="11" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
109 changes: 109 additions & 0 deletions day05assignment/src/me/day05/practice/practice01/Electronic.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
package me.day05.practice.practice01;

import me.day05.practice.practice01.constant.AuthMethod;
import me.day05.practice.practice01.constant.Company;

import java.time.LocalDate;
import java.util.Arrays;
import java.util.Objects;

public class Electronic {
private static int autoIncrementNumber = 0;

Choose a reason for hiding this comment

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

static 변수를 가장 상위에 위치하도록 해주셨네요. 아주 굿!

private String productNo;
private String modelName;
private Company companyName;
private String dateOfDate;
private AuthMethod[] authMethods;

public Electronic(String productNo,
String modelName,
Company companyName,
String dateOfDate
) {
this.productNo = this.generateProductNo();

Choose a reason for hiding this comment

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

함수로 분리하는 센스! 너무 좋습니다.

this.modelName = modelName;
this.companyName = companyName;
this.dateOfDate = dateOfDate;
this.authMethods = new AuthMethod[10];
}

private String generateProductNo() {
StringBuilder builder = new StringBuilder();
String id = String.format("%04d", ++autoIncrementNumber);

Choose a reason for hiding this comment

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

정규식 사용으로 코드가 한결 간단해 졌어요 아주 잘하셨습니다! 👍

String generatedDate = LocalDate.now().toString().replace("-", "").substring(2);
builder.append(generatedDate).append(id);
return builder.toString();
}

public String getProductNo() {
return 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 getDateOfDate() {
return dateOfDate;
}

public void setDateOfDate(String dateOfDate) {
this.dateOfDate = dateOfDate;
}

public AuthMethod[] getAuthMethods() {
return authMethods;
}

public void setAuthMethods(AuthMethod[] authMethods) {
this.authMethods = authMethods;
}

@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(modelName, that.modelName)) return false;
if (companyName != that.companyName) return false;
if (!Objects.equals(dateOfDate, that.dateOfDate)) 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 + (modelName != null ? modelName.hashCode() : 0);
result = 31 * result + (companyName != null ? companyName.hashCode() : 0);
result = 31 * result + (dateOfDate != null ? dateOfDate.hashCode() : 0);
result = 31 * result + Arrays.hashCode(authMethods);
return result;
}

@Override
public String toString() {
return "Electronic{" +
"productNo='" + productNo + "'" +
", modelName='" + modelName + "'" +
", companyName=" + companyName +
", dateOfDate='" + dateOfDate + "'" +
", authMethod=" + Arrays.toString(authMethods) +
'}';
}
}
126 changes: 126 additions & 0 deletions day05assignment/src/me/day05/practice/practice01/User.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
package me.day05.practice.practice01;

import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Objects;

public class User {
private String userId;
private String userPassword;
private String userPhoneNumber;
private String userEmail;
private String userBirthDate;
private Electronic[] electronicDevices;
private LocalDateTime registerTime;

Choose a reason for hiding this comment

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

좋아요:) 센스 있습니다.


public User(String userId,
String userPassword,
String userPhoneNumber,
String userEmail,
String userBirthDate
) {
this.electronicDevices = new Electronic[10];
this.registerTime = LocalDateTime.now();
this.userId = userId;
this.userPassword = userPassword;
this.userPhoneNumber = userPhoneNumber;
this.userEmail = userEmail;
this.userBirthDate = userBirthDate;
}

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 String getUserPhoneNumber() {
return userPhoneNumber;
}

public void setUserPhoneNumber(String userPhoneNumber) {
this.userPhoneNumber = userPhoneNumber;
}

public String getUserEmail() {
return userEmail;
}

public void setUserEmail(String userEmail) {
this.userEmail = userEmail;
}

public String getUserBirthDate() {
return userBirthDate;
}

public void setUserBirthDate(String userBirthDate) {
this.userBirthDate = userBirthDate;
}

public LocalDateTime getRegisterTime() {
return registerTime;
}

public void setRegisterTime(LocalDateTime registerTime) {
this.registerTime = registerTime;
}

public Electronic[] getElectronicDevices() {
return electronicDevices;
}

public void setElectronicDevices(Electronic[] electronicDevices) {
this.electronicDevices = electronicDevices;
}

@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || this.getClass() != obj.getClass()) return false;

User user = (User) obj;

if (!Objects.equals(userId, user.userId)) return false;
if (!Objects.equals(userPassword, user.userPassword)) return false;
if (!Objects.equals(userPhoneNumber, user.userPhoneNumber)) return false;
if (!Objects.equals(userEmail, user.userEmail)) return false;
if (!Objects.equals(userBirthDate, user.userBirthDate)) return false;

return Objects.equals(registerTime, user.registerTime);

Choose a reason for hiding this comment

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

요 부분은 그래도 잘하셨네요! 그런데 이렇게 작성을 하게 되면 놓치는 부분이 생길 수도 있을 것 같아요! 물론 훈섭님은 꼼꼼하시니까 놓치지 않겠지만! 혹시 모르는 일이니까요~ㅎㅎ

}

@Override
public int hashCode() {
return Objects.hash(userId,
userPassword,
userPhoneNumber,
userEmail,
userBirthDate,
registerTime
);
}

@Override
public String toString() {
return "User{" +
"userId='" + userId + "'" +
", userPassword='" + userPassword + "'" +
", userPhoneNumber='" + userPhoneNumber + "'" +
", userEmail='" + userEmail + "'" +
", userBirthDate='" + userBirthDate + "'" +
", electronicDevices=" + Arrays.toString(electronicDevices) +
", registerTime=" + registerTime +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package me.day05.practice.practice01.constant;

public enum AuthMethod {
FINGER_PRINT, PATTERN, PIN, FACE;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package me.day05.practice.practice01.constant;

public enum Company {
SAMSUNG, LG, APPLE;
}
Loading