-
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 LeeJaewon #32
Open
Pull-Stack
wants to merge
2
commits into
FastCampusKDTBackend:main
Choose a base branch
from
Pull-Stack:Jaewon_Lee
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package me.day05.practice; | ||
|
||
public enum AuthMethod { | ||
FINGERPRINT_AUTHENTICATION, PATTERN_AUTHENTICATION, PIN_AUTHENTICATION, FACIAL_AUTHENTICATION | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package me.day05.practice; | ||
|
||
public enum Company { | ||
SAMSUNG, LG, APPLE | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package me.day05.practice; | ||
|
||
import java.time.LocalDate; | ||
import java.time.format.DateTimeFormatter; | ||
import java.util.Arrays; | ||
import java.util.Objects; | ||
|
||
public class Electronic { | ||
private static Long registerNo; | ||
private String productNo; | ||
private String modelName; | ||
private Company companyName; | ||
private LocalDate dateOfMade; | ||
private AuthMethod[] authMethods; | ||
|
||
public Electronic() { | ||
if (registerNo == null) { | ||
registerNo = 0L; | ||
} | ||
this.productNo = LocalDate.now().format(DateTimeFormatter.ofPattern("YYMMdd")) | ||
+ (String.format("%04d", ++registerNo)); | ||
} | ||
|
||
public static Long getRegisterNo() { | ||
return registerNo; | ||
} | ||
|
||
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 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; | ||
return productNo.equals(that.productNo) && Objects.equals(modelName, that.modelName) | ||
&& companyName == that.companyName && Objects.equals(dateOfMade, that.dateOfMade) | ||
&& Arrays.equals(authMethods, that.authMethods); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(productNo); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Electronic{" + | ||
"productNo='" + productNo + '\'' + | ||
", modelName='" + modelName + '\'' + | ||
", companyName=" + companyName + | ||
", dateOfMade=" + dateOfMade + | ||
", authMethods=" + Arrays.toString(authMethods) + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package me.day05.practice; | ||
|
||
import java.util.Arrays; | ||
|
||
public class Electronics { | ||
private static Electronics electronics; | ||
private Electronic[] electronicList; | ||
|
||
private Electronics() { | ||
|
||
} | ||
|
||
public static Electronics getInstance() { | ||
if (electronics == null) { | ||
electronics = new Electronics(); | ||
} | ||
return Electronics.electronics; | ||
} | ||
|
||
public Electronic findByProductNo(String productNo) { | ||
return Arrays.stream(this.electronicList) | ||
.filter(electronic -> electronic.getProductNo().equals(productNo)) | ||
.findFirst() | ||
.orElse(null); | ||
} | ||
|
||
Electronic[] groupByCompany(Company company) { | ||
return Arrays.stream(this.electronicList) | ||
.filter(electronic -> electronic.getCompanyName().equals(company)) | ||
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. CompanyName과 Company 용어를 통일하면 어떨까요? 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. 네 반환되는 값이 Company array이니 메소드명을 groupByCompany()으로 바꾸는게 좋아보입니다! |
||
.toArray(Electronic[]::new); | ||
} | ||
|
||
Electronic[] groupByAuthMethod(AuthMethod authMethod) { | ||
return Arrays.stream(this.electronicList) | ||
.filter( | ||
electronic -> Arrays.stream(electronic.getAuthMethods()) | ||
.anyMatch(authMethods -> authMethods.equals(authMethod)) | ||
).toArray(Electronic[]::new); | ||
} | ||
|
||
public Electronic[] getElectronicList() { | ||
return electronicList; | ||
} | ||
|
||
public void setElectronicList(Electronic[] electronicList) { | ||
this.electronicList = electronicList; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package me.day05.practice; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.util.Arrays; | ||
import java.util.Objects; | ||
|
||
public class User implements Cloneable { | ||
private String userId; | ||
private String userPassword; | ||
private String userPhoneNumber; | ||
private String email; | ||
private LocalDate userBirthDate; | ||
private Electronic[] electronicDevices; | ||
private LocalDateTime registerTime; | ||
|
||
public User() { | ||
this.registerTime = LocalDateTime.now(); | ||
} | ||
|
||
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 getEmail() { | ||
return email; | ||
} | ||
|
||
public void setEmail(String email) { | ||
this.email = email; | ||
} | ||
|
||
public LocalDate getUserBirthDate() { | ||
return userBirthDate; | ||
} | ||
|
||
public void setUserBirthDate(LocalDate userBirthDate) { | ||
this.userBirthDate = userBirthDate; | ||
} | ||
|
||
public Electronic[] getElectronicDevices() { | ||
return electronicDevices; | ||
} | ||
|
||
public void setElectronicDevices(Electronic[] electronicDevices) { | ||
this.electronicDevices = electronicDevices; | ||
} | ||
|
||
public LocalDateTime getRegisterTime() { | ||
return registerTime; | ||
} | ||
|
||
public void setRegisterTime(LocalDateTime registerTime) { | ||
this.registerTime = registerTime; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) | ||
return true; | ||
if (o == null || getClass() != o.getClass()) | ||
return false; | ||
User user = (User)o; | ||
return userId.equals(user.userId); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(userId); | ||
} | ||
|
||
@Override | ||
protected Object clone() throws CloneNotSupportedException { | ||
return super.clone(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "User{" + | ||
"userId='" + userId + '\'' + | ||
", userPassword='" + userPassword + '\'' + | ||
", userPhoneNumber='" + userPhoneNumber + '\'' + | ||
", email='" + email + '\'' + | ||
", userBirthDate=" + userBirthDate + | ||
", electronicDevices=" + Arrays.toString(electronicDevices) + | ||
", registerTime=" + registerTime + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package me.day05.practice; | ||
|
||
import java.util.Arrays; | ||
|
||
import me.day05.practice.exception.DuplicateUserException; | ||
|
||
public class Users { | ||
private static final int DEFAULT_CAPACITY = 20; | ||
private static Users users; | ||
private User[] userList; | ||
|
||
private Users() { | ||
userList = new User[DEFAULT_CAPACITY]; | ||
} | ||
|
||
public static Users getInstance() { | ||
if (users == null) { | ||
Users.users = new Users(); | ||
} | ||
return Users.users; | ||
} | ||
|
||
public User findByUserId(String userId) { | ||
return Arrays.stream(this.userList) | ||
.filter((user -> user.getUserId().equals(userId))) | ||
.findFirst() | ||
.orElse(null); | ||
} | ||
|
||
public User copy(User user) throws CloneNotSupportedException { | ||
return (User)(user.clone()); | ||
} | ||
|
||
public User[] getUserList() { | ||
return userList; | ||
} | ||
|
||
public void setUserList(User[] userList) { | ||
this.userList = userList; | ||
} | ||
|
||
private boolean isDuplicateUser(User user) { | ||
return Arrays.stream(this.userList) | ||
.anyMatch(users -> users.getUserId().equals(user.getUserId())); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
굳