-
Notifications
You must be signed in to change notification settings - Fork 0
Java Assignment3 upload by MiyeonLee #27
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 all commits
c9f0f51
cb76572
614ff25
8ad6ae7
0a1f409
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,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-19"> | ||
<attributes> | ||
<attribute name="module" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/bin/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>Assignment3</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=19 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=19 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning | ||
org.eclipse.jdt.core.compiler.release=enabled | ||
org.eclipse.jdt.core.compiler.source=19 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
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,3 @@ | ||
package me.day05.practice.Practice01; | ||
|
||
public enum Company {SAMSUNG, LG, APPLE } //제조 회사명 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
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 static int serialNum = 0; | ||
private String modelName; | ||
private Company companyName; | ||
private String dateOfMade; | ||
private AuthMethod[] authMethod; | ||
|
||
|
||
public Electronic(){ | ||
serialNum++; | ||
productNo = LocalDate.now().format(DateTimeFormatter.ofPattern("yyMMdd")) + String.format("%04d",serialNum); | ||
} | ||
|
||
public Electronic(String modelName, Company companyName, String dateOfMade, AuthMethod[] authMethod) { | ||
serialNum++; | ||
this.productNo = LocalDate.now().format(DateTimeFormatter.ofPattern("yyMMdd")) + String.format("%04d", serialNum); | ||
this.modelName = modelName; | ||
this.companyName = companyName; | ||
this.dateOfMade = dateOfMade; | ||
this.authMethod = authMethod; | ||
|
||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(productNo, modelName, dateOfMade, companyName, authMethod); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (!(obj instanceof Electronic)) return false; | ||
|
||
Electronic electronic = (Electronic) obj; | ||
return (this.productNo == electronic.productNo) || (this.modelName == electronic.modelName) | ||
|| (this.dateOfMade == electronic.dateOfMade) || (this.companyName == electronic.companyName) | ||
|| (this.authMethod.equals(electronic.authMethod)); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "electronic{productNo:" + productNo + | ||
", modelName:" + modelName + | ||
", companyName:" + companyName + | ||
", dateOfMade:" + dateOfMade + | ||
", authMethod:" + Arrays.toString(authMethod) + "}"; | ||
} | ||
|
||
|
||
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 String getDateOfMade() { | ||
return dateOfMade; | ||
} | ||
|
||
public void setDateOfMade(String dateOfMade) { | ||
this.dateOfMade = dateOfMade; | ||
} | ||
public void setCompanyName(Company companyName){ | ||
this.companyName = companyName; | ||
} | ||
public Company getCompanyName(){ | ||
return companyName; | ||
} | ||
|
||
public AuthMethod[] getAuthMethod() { | ||
return authMethod; | ||
} | ||
|
||
public void setAuthMethod(AuthMethod[] authMethod) { | ||
this.authMethod = authMethod; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package me.day05.practice.Practice01; | ||
|
||
import java.time.LocalTime; | ||
import java.util.Objects; | ||
|
||
public class User { | ||
|
||
private String userId; | ||
private String userPassword; | ||
private int userPhoneNumber; | ||
private String userEmail; | ||
private int userBirthDate; | ||
private String[] electronicDevices; | ||
public LocalTime registerTime; | ||
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. Electronic 클래스의 productNo은 LocalTime을 사용하라고 언급되어 있는데 근데 멘토님 코멘트 보고 생각해보니, 회원정보 등록 시간에 대한 필드니까 날짜와 시간이 같이 출력되도록 하는 것이 좋을 것 같습니다. 참고해서 수정해보겠습니다.🤓 |
||
|
||
|
||
public User(){ | ||
registerTime = LocalTime.now(); | ||
} | ||
|
||
public User(String userId, String userPassword, int userPhoneNumber, String userEmail, int userBirthDate, | ||
String[] electronicDevices) { | ||
this.userId = userId; | ||
this.userPassword = userPassword; | ||
this.userPhoneNumber = userPhoneNumber; | ||
this.userEmail = userEmail; | ||
this.userBirthDate = userBirthDate; | ||
this.electronicDevices = electronicDevices; | ||
this.registerTime = LocalTime.now(); | ||
} | ||
|
||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(userId, userPassword, userPhoneNumber, userEmail, userBirthDate, electronicDevices, | ||
registerTime); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (!(obj instanceof User)) | ||
return false; | ||
|
||
User user = (User) obj; | ||
return (this.userId == user.userId) || (this.userPassword == user.userPassword) | ||
|| (this.userPhoneNumber == user.userPhoneNumber) || (this.userEmail == user.userEmail) | ||
|| (this.userBirthDate == user.userBirthDate) || (this.electronicDevices == user.electronicDevices) | ||
|| (this.registerTime == user.registerTime); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "User{userId:" + userId + | ||
", userPassword:" + userPassword + | ||
", userPhonNumber:" + userPhoneNumber + | ||
", userEmail:" + userEmail + | ||
", userBirthDat:" + userBirthDate + | ||
", electronicDevice:" + electronicDevices + | ||
", registerTime:" + registerTime + | ||
"}"; | ||
} | ||
|
||
|
||
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 String[] getElectronicDevices() { | ||
return electronicDevices; | ||
} | ||
|
||
public void setElectronicDevices(String[] electronicDevices) { | ||
this.electronicDevices = electronicDevices; | ||
} | ||
|
||
public LocalTime getTime() { | ||
return this.registerTime; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package me.day05.practice.Practice02; | ||
|
||
import me.day05.practice.Practice01.User; | ||
|
||
import java.util.Arrays; | ||
import java.util.Objects; | ||
|
||
public class Users { | ||
|
||
private User[] userList; | ||
private static Users instance; | ||
|
||
private Users() {} | ||
|
||
public static Users getInstance() { | ||
if(instance == null) instance = new Users(); | ||
|
||
return instance; | ||
} | ||
|
||
User findByUserId(String userId) { | ||
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. 접근 제한자가 없는 이유가 있을까요? |
||
for(User user : userList) { | ||
if(user.getUserId().equals(userId)) | ||
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 user; | ||
} | ||
return null; | ||
} | ||
|
||
User copy(User user) { | ||
User userCopy = new User(user.getUserId(), user.getUserPassword(), user.getUserPhoneNumber() | ||
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.
|
||
, user.getUserEmail(), user.getUserBirthDate(), user.getElectronicDevices()); | ||
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 userCopy; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(userList); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if(!(obj instanceof Users)) return false; | ||
|
||
Users list = (Users)obj; | ||
return Arrays.equals(userList, list.userList); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "{userList:" + Arrays.toString(userList) + "}"; | ||
} | ||
|
||
public User[] getUserList() { | ||
return userList; | ||
} | ||
|
||
public void setUserList(User[] userList) { | ||
this.userList = userList; | ||
} | ||
} |
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.
중복 코드를 줄여보세요.