-
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 TaeIlKIm #13
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.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
package src.practice01; | ||
|
||
import src.practice01.db.AuthMethod; | ||
import src.practice01.db.Company; | ||
|
||
import java.time.LocalDate; | ||
import java.time.format.DateTimeFormatter; | ||
import java.util.ArrayList; | ||
import java.util.Objects; | ||
|
||
public class Electronic { | ||
private static int serialNumber = 0; | ||
|
||
String productNo; | ||
String modelName; | ||
Company companyName; | ||
LocalDate dateOfMade; | ||
ArrayList<AuthMethod> authMethods = new ArrayList<>(); | ||
|
||
public Electronic ( | ||
String productNo, String modelName, | ||
Company companyName, LocalDate dateOfMade, | ||
AuthMethod auth | ||
|
||
) { | ||
LocalDate today = LocalDate.now(); | ||
|
||
|
||
serialNumber++; | ||
this.modelName = modelName; | ||
|
||
this.productNo = today.format(DateTimeFormatter.ofPattern("yyMMdd")); | ||
this.productNo += String.format("%04d", serialNumber); | ||
this.companyName = companyName; | ||
authMethods.add(auth); | ||
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. authMethods도 리스트로 받는것이 좋지 않을까요? |
||
} | ||
|
||
public static int getSerialNumber() { | ||
return serialNumber; | ||
} | ||
|
||
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 Company getCompanyName() { | ||
return companyName; | ||
} | ||
|
||
public void setCompanyName(Company companyName) { | ||
this.companyName = companyName; | ||
} | ||
|
||
public LocalDate getDateOfMade() { | ||
return dateOfMade; | ||
} | ||
|
||
public void setDateOfMade(LocalDate dateOfMade) { | ||
this.dateOfMade = dateOfMade; | ||
} | ||
|
||
public ArrayList<AuthMethod> getAuthMethods() { | ||
return authMethods; | ||
} | ||
|
||
public void setAuthMethods(ArrayList<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; | ||
return Objects.equals(productNo, that.productNo) && | ||
Objects.equals(modelName, that.modelName) && companyName == that.companyName && | ||
Objects.equals(dateOfMade, that.dateOfMade) && | ||
Objects.equals(authMethods, that.authMethods); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(productNo, modelName, companyName, dateOfMade, authMethods); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Electronic{" + | ||
"productNo='" + productNo + '\'' + | ||
", modelName='" + modelName + '\'' + | ||
", companyName=" + companyName + | ||
", dateOfMade=" + dateOfMade + | ||
", authMethods=" + authMethods + | ||
'}'; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
package src.practice01; | ||
|
||
import java.time.LocalDate; | ||
import java.util.ArrayList; | ||
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 ArrayList<Electronic> electronicDevices = new ArrayList<>(); | ||
private LocalDate registerTime; | ||
|
||
public User() {} | ||
|
||
public User ( | ||
String userId, | ||
String userPassword, | ||
String userPhoneNumber, | ||
String userEmail, | ||
String 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.
|
||
) { | ||
this.userId = userId; | ||
this.userPassword = userPassword; | ||
this.userPhoneNumber = userPhoneNumber; | ||
this.userEmail = userEmail; | ||
this.userBirthDate = 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.
|
||
|
||
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 ArrayList<Electronic> getElectronicDevices() { | ||
return electronicDevices; | ||
} | ||
|
||
public void setElectronicDevices(ArrayList<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) && | ||
Objects.equals(userPassword, user.userPassword) && | ||
Objects.equals(userPhoneNumber, user.userPhoneNumber) && | ||
Objects.equals(userEmail, user.userEmail) && | ||
Objects.equals(userBirthDate, user.userBirthDate) && | ||
Objects.equals(electronicDevices, user.electronicDevices) && | ||
Objects.equals(registerTime, user.registerTime); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(userId, userPassword, | ||
userPhoneNumber, userEmail, userBirthDate, | ||
electronicDevices, registerTime); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "User{" + | ||
"userId='" + userId + '\'' + | ||
", userPassword='" + userPassword + '\'' + | ||
", userPhoneNumber='" + userPhoneNumber + '\'' + | ||
", userEmail='" + userEmail + '\'' + | ||
", userBirthDate='" + userBirthDate + '\'' + | ||
", electronicDevices=" + electronicDevices + | ||
", registerTime=" + registerTime + | ||
'}'; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package src.practice01.db; | ||
|
||
public enum AuthMethod { | ||
FINGERPRINT, | ||
PATTERN, | ||
PIN, | ||
FACE | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package src.practice01.db; | ||
|
||
public enum Company { | ||
SAMSUN, | ||
LG, | ||
APPLE | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package src.practice02; | ||
|
||
import src.practice01.User; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Objects; | ||
|
||
public class Users { | ||
private ArrayList<User> userList = new ArrayList<>(); | ||
|
||
// 싱글톤 | ||
private static Users instance; | ||
public Users() {} | ||
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 static Users getInstance() { | ||
if (instance == null) { | ||
instance = new Users(); | ||
} | ||
return instance; | ||
} | ||
|
||
public ArrayList<User> getUserList() { | ||
return userList; | ||
} | ||
|
||
public void setUserList(ArrayList<User> userList) { | ||
this.userList = userList; | ||
} | ||
|
||
public User findByUserId(String userId) { | ||
for (User user : userList) { | ||
if (userId.equals(user.getUserId())) { | ||
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; | ||
} | ||
|
||
public User Copy(User user) { | ||
User copyUser = new User(); | ||
copyUser.setUserId(user.getUserId()); | ||
copyUser.setUserPassword(user.getUserPassword()); | ||
copyUser.setUserEmail(user.getUserEmail()); | ||
copyUser.setUserPhoneNumber(user.getUserPhoneNumber()); | ||
copyUser.setUserBirthDate(user.getUserBirthDate()); | ||
copyUser.setElectronicDevices(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 copyUser; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
Users users = (Users) o; | ||
return Objects.equals(userList, users.userList); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(userList); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Users{" + | ||
"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.
접근제한자가 없는 이유가 있을까요?