-
Notifications
You must be signed in to change notification settings - Fork 0
Java Assignment3 upload by JongMinJeong #16
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
Open
Across826
wants to merge
2
commits into
FastCampusKDTBackend:main
Choose a base branch
from
Across826:JongMinJeong
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 hidden or 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.Practice01; | ||
|
||
public enum Auth { | ||
FingerPrint,Pattern,PIN,Face; | ||
} |
This file contains hidden or 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.Practice01; | ||
|
||
public enum Company { | ||
SAMSUNG,LG,APPLE; | ||
} |
This file contains hidden or 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,99 @@ | ||
package me.day05.practice.Practice01; | ||
|
||
import java.time.LocalDate; | ||
import java.time.format.DateTimeFormatter; | ||
import java.util.Objects; | ||
|
||
public class Electronic { | ||
private static int serialNum = 0; | ||
|
||
private String productNO; | ||
private String modelName; | ||
private Company CompanyName; | ||
private LocalDate dateOfMade; | ||
private Auth[] authMethod; | ||
|
||
public Electronic(String modelName, Company companyName, Auth[] authMethod) { | ||
serialNum++; | ||
productNO = setProductNO(); | ||
this.modelName = modelName; | ||
CompanyName = companyName; | ||
this.dateOfMade = LocalDate.now(); | ||
this.authMethod = authMethod; | ||
} | ||
|
||
public Electronic() { | ||
serialNum++; | ||
productNO = setProductNO(); | ||
} | ||
|
||
public String getProductNO() { | ||
return productNO; | ||
} | ||
|
||
public String setProductNO() { | ||
LocalDate localDate = LocalDate.now(); | ||
String serialNO = localDate.format(DateTimeFormatter.ofPattern("yyMMdd")); | ||
serialNO += String.format("%04d",serialNum); | ||
|
||
return serialNO; | ||
} | ||
|
||
public String getModelName() { | ||
return modelName; | ||
} | ||
|
||
public void setModelName(String modelName) { | ||
this.modelName = modelName; | ||
} | ||
|
||
public Company getCompanyName() { | ||
return CompanyName; | ||
} | ||
|
||
public void setCompanyName(Company companyName) { | ||
CompanyName = companyName; | ||
} | ||
|
||
public LocalDate getDateOfMade() { | ||
return dateOfMade; | ||
} | ||
|
||
public void setDateOfMade(LocalDate dateOfMade) { | ||
this.dateOfMade = dateOfMade; | ||
} | ||
|
||
public Auth[] getAuthMethod() { | ||
return authMethod; | ||
} | ||
|
||
public void setAuthMethod(Auth[] authMethod) { | ||
this.authMethod = authMethod; | ||
} | ||
|
||
@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) && authMethod == that.authMethod; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(productNO, modelName, CompanyName, dateOfMade, authMethod); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Electronic{" + | ||
"productNO='" + productNO + '\'' + | ||
", modelName='" + modelName + '\'' + | ||
", CompanyName=" + CompanyName + | ||
", dateOfMade=" + dateOfMade + | ||
", authMethod=" + authMethod + | ||
'}'; | ||
} | ||
|
||
} | ||
|
This file contains hidden or 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,120 @@ | ||
package me.day05.practice.Practice01; | ||
|
||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
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; | ||
static final int DEFAULT_CAPACITY = 10; | ||
|
||
public User(String userId, String userPassword, String userPhoneNumber, String userEmail, String userBirthDate, Electronic[] electronicDevices, LocalDateTime registerTime) { | ||
this.userId = userId; | ||
this.userPassword = userPassword; | ||
this.userPhoneNumber = userPhoneNumber; | ||
this.userEmail = userEmail; | ||
this.userBirthDate = userBirthDate; | ||
this.electronicDevices = new Electronic[DEFAULT_CAPACITY]; | ||
this.registerTime = LocalDateTime.now(); | ||
} | ||
|
||
public User() { | ||
this.electronicDevices = new Electronic[DEFAULT_CAPACITY]; | ||
this.registerTime = LocalDateTime.now(); | ||
} | ||
|
||
public String getUserId() { | ||
|
||
return userId; | ||
} | ||
|
||
public void setUserId(String userId) { | ||
this.userId = userId; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "User{" + | ||
"userId='" + userId + '\'' + | ||
", userPassword='" + userPassword + '\'' + | ||
", userPhoneNumber='" + userPhoneNumber + '\'' + | ||
", userEmail='" + userEmail + '\'' + | ||
", userBirthDate='" + userBirthDate + '\'' + | ||
", electronicDevices=" + Arrays.toString(electronicDevices) + | ||
", registerTime=" + registerTime + | ||
'}'; | ||
} | ||
|
||
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.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); | ||
} | ||
|
||
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 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) && Arrays.equals(electronicDevices, user.electronicDevices) && Objects.equals(registerTime, user.registerTime); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = Objects.hash(userId, userPassword, userPhoneNumber, userEmail, userBirthDate, registerTime); | ||
result = 31 * result + Arrays.hashCode(electronicDevices); | ||
return result; | ||
} | ||
|
||
|
||
} |
This file contains hidden or 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,83 @@ | ||
package me.day05.practice.Practice02; | ||
|
||
import me.day05.practice.Practice01.User; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Objects; | ||
|
||
public class Users { | ||
private ArrayList<User> userList = new ArrayList<>(); | ||
|
||
public Users(ArrayList<User> userList) { | ||
this.userList = userList; | ||
} | ||
|
||
public Users () {} | ||
public ArrayList<User> getUserList() { | ||
return userList; | ||
} | ||
|
||
public void setUserList(ArrayList<User> userList) { | ||
this.userList = userList; | ||
} | ||
|
||
public static void setInstance(Users instance) { | ||
Users.instance = instance; | ||
} | ||
|
||
@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 + | ||
'}'; | ||
} | ||
|
||
// Users 클래스의 객체를 싱글톤으로 생성하는 함수를 작성하시오. | ||
private static Users instance; | ||
public static Users getInstance() { | ||
if (instance == null) { | ||
instance = new Users(); | ||
} | ||
|
||
return instance; | ||
} | ||
|
||
|
||
//회원 아이디 userId를 통해 인자로 주어진 회원번호에 해당하는 회원을 반환하는 함수를 작성하시오 | ||
|
||
public User findByUserId(String userId) { | ||
for (User user : userList) { | ||
if (userId.equals(user.getUserId())) { | ||
return user; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
// 인자로 주어진 회원 정보를 깊은 복사 (deepCopy) 하는 함수를 작성하시오. | ||
public User Copy(User user) { | ||
User userCopy = new User(); | ||
userCopy.setUserId(user.getUserId()); | ||
userCopy.setUserPassword(user.getUserPassword()); | ||
userCopy.setUserEmail(user.getUserEmail()); | ||
userCopy.setUserPhoneNumber(user.getUserPhoneNumber()); | ||
userCopy.setUserBirthDate(user.getUserBirthDate()); | ||
userCopy.setElectronicDevices(user.getElectronicDevices()); | ||
|
||
return userCopy; | ||
} | ||
|
||
} |
Oops, something went wrong.
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.
자바 컨벤션에서 함수의 첫글자는 소문자를 권장합니다