-
Notifications
You must be signed in to change notification settings - Fork 0
Java Assignment3 upload by ParkSeongWook #24
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
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package me.day05.practice.Practice01; | ||
|
||
public enum Auth { | ||
FingerPrint, Pattern, PIN, Face; | ||
} |
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; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package me.day05.practice.Practice01; | ||
|
||
import java.time.LocalDate; | ||
import java.util.Arrays; | ||
|
||
public class Electronic { | ||
private static int count = 0; | ||
private final String productNo; | ||
private final String modelName; | ||
private final Company companyName; | ||
private final LocalDate dateOfMade; | ||
private final Auth[] authMethods; | ||
|
||
public Electronic(String modelName, Company companyName, LocalDate dateOfMade, Auth[] authMethods) { | ||
count++; | ||
this.productNo = LocalDate.now().toString().replace("-", "").substring(2) + String.format("%04d", count); | ||
this.modelName = modelName; | ||
this.companyName = companyName; | ||
this.dateOfMade = dateOfMade; | ||
this.authMethods = authMethods; | ||
} | ||
|
||
public String getProductNo() { | ||
return productNo; | ||
} | ||
|
||
public String getModelName() { | ||
return modelName; | ||
} | ||
|
||
public Company getCompanyName() { | ||
return companyName; | ||
} | ||
|
||
public LocalDate getDateOfMade() { | ||
return dateOfMade; | ||
} | ||
|
||
public Auth[] getAuthMethods() { | ||
return authMethods; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Electronic{" + | ||
"productNo='" + productNo + '\'' + | ||
", modelName='" + modelName + '\'' + | ||
", companyName=" + companyName + | ||
", dateOfMade=" + dateOfMade + | ||
", authMethods=" + Arrays.toString(authMethods) + | ||
'}'; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package me.day05.practice.Practice01; | ||
|
||
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 final String registerTime; | ||
|
||
public User(String userId, String userPassword, String userPhoneNumber, String userEmail, String userBirthDate, Electronic[] electronicDevices) { | ||
this.userId = userId; | ||
this.userPassword = userPassword; | ||
this.userPhoneNumber = userPhoneNumber; | ||
this.userEmail = userEmail; | ||
this.userBirthDate = userBirthDate; | ||
this.electronicDevices = electronicDevices; | ||
this.registerTime = String.valueOf(System.currentTimeMillis()); | ||
} | ||
|
||
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 Electronic[] getElectronicDevices() { | ||
return electronicDevices; | ||
} | ||
|
||
public void setElectronicDevices(Electronic[] electronicDevices) { | ||
this.electronicDevices = electronicDevices; | ||
} | ||
|
||
public String getRegisterTime() { | ||
return registerTime; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(userId, userPassword, userPhoneNumber, userEmail, userBirthDate, electronicDevices); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "User{" + | ||
"userId=" + userId + | ||
", userPassword='" + userPassword + '\'' + | ||
", userPhoneNumber='" + userPhoneNumber + '\'' + | ||
", userEmail='" + userEmail + '\'' + | ||
", userBirthDate='" + userBirthDate + '\'' + | ||
", electronicDevices=" + electronicDevices + | ||
'}'; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package me.day05.practice.Practice02; | ||
|
||
import me.day05.practice.Practice01.User; | ||
|
||
import java.util.Arrays; | ||
|
||
|
||
public class Users { | ||
private static Users instance = null; | ||
private User[] userList; | ||
|
||
private Users() { | ||
userList = new User[0]; | ||
} | ||
|
||
public static Users getInstance() { | ||
if (instance == null) { | ||
instance = new Users(); | ||
} | ||
return instance; | ||
} | ||
|
||
public User[] getUserList() { | ||
return userList; | ||
} | ||
|
||
public void setUserList(User[] userList) { | ||
this.userList = userList; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Arrays.hashCode(userList); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
if (obj == null || getClass() != obj.getClass()) { | ||
return false; | ||
} | ||
Users users = (Users) obj; | ||
return Arrays.equals(userList, users.userList); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Users{" + | ||
"userList=" + Arrays.toString(userList) + | ||
'}'; | ||
} | ||
|
||
public User findByUserId(String userId) { | ||
for (User user : userList) { | ||
if (user.getUserId().equals(userId)) { | ||
return user; | ||
} | ||
} | ||
return null; | ||
} | ||
public User Copy(User 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. 자바에서 함수의 첫글자는 소문자로 하는게 권장됩니다.(카멜케이스로) |
||
User userCopy = new User(user.getUserId(), user.getUserPassword(), user.getUserPhoneNumber(), | ||
user.getUserEmail(), user.getUserBirthDate(), user.getElectronicDevices()); | ||
return userCopy; | ||
} | ||
} |
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은 열거형 '상수' 이기 때문에 대문자로 작성하는게 자바에서 권장하는 컨벤션입니다. 띄어쓰기 같은 경우는 언더바(_)로 구분지으면 되구요. FINGER_PRINT 같이요