diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1847a1b --- /dev/null +++ b/.gitignore @@ -0,0 +1,30 @@ +# Created by https://www.toptal.com/developers/gitignore/api/java +# Edit at https://www.toptal.com/developers/gitignore?templates=java + +### Java ### +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +replay_pid* + +# End of https://www.toptal.com/developers/gitignore/api/java \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..60eee04 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,34 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +### Java template +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +replay_pid* + diff --git a/.idea/KDTBE5_Java_Assignment3.iml b/.idea/KDTBE5_Java_Assignment3.iml new file mode 100644 index 0000000..b107a2d --- /dev/null +++ b/.idea/KDTBE5_Java_Assignment3.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/discord.xml b/.idea/discord.xml new file mode 100644 index 0000000..30bab2a --- /dev/null +++ b/.idea/discord.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..4458232 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..12e7bfa --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/me/day05/practice/practice01/AuthMethod.java b/me/day05/practice/practice01/AuthMethod.java new file mode 100644 index 0000000..4e98a7f --- /dev/null +++ b/me/day05/practice/practice01/AuthMethod.java @@ -0,0 +1,5 @@ +package me.day05.practice.practice01; + +public enum AuthMethod { + FINGERPRINT, PATTERN, PIN, FACE +} diff --git a/me/day05/practice/practice01/Company.java b/me/day05/practice/practice01/Company.java new file mode 100644 index 0000000..375bb45 --- /dev/null +++ b/me/day05/practice/practice01/Company.java @@ -0,0 +1,5 @@ +package me.day05.practice.practice01; + +public enum Company { + SAMSUNG, LG, APPLE +} diff --git a/me/day05/practice/practice01/Electronic.java b/me/day05/practice/practice01/Electronic.java new file mode 100644 index 0000000..533543f --- /dev/null +++ b/me/day05/practice/practice01/Electronic.java @@ -0,0 +1,140 @@ +package me.day05.practice.practice01; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; +import java.util.Arrays; +import java.util.Objects; + +public class Electronic { + + private static int objectNo = 0; //등록된제품순서. + private String productNo; //제품일련번호 + private String modelName; //전자기기 모델명 + + private Company companyName; //제조회사명 + private String dateOfMade; //생산일자 + + private AuthMethod[] authMethods; //본인인증방법 , 배열로정의 + + + + public Electronic() { + objectNo++; + } + // 기본생성자 + + + public Electronic( String modelName, Company companyName, String dateOfMade, AuthMethod[] authMethods) { + objectNo++; + //this.productNo = LocalDate.now().format(DateTimeFormatter.ofPattern("yyMMdd")) + String.format("%04d", objectNo) ; + + StringBuilder sb = new StringBuilder(); + sb.append(LocalDate.now().format(DateTimeFormatter.ofPattern("yyMMdd"))); + sb.append(String.format("%04d", objectNo)); + + // 날짜 형식 검증 + if (!isValidDateFormat(dateOfMade)) { + dateOfMade = "20000101"; // 기본값으로 지정 + } + + this.productNo = sb.toString(); + this.modelName = modelName; + this.companyName = companyName; + this.dateOfMade = dateOfMade; + this.authMethods = authMethods; + + + } + //5개의 인자를 가지는 생성자 + + private boolean isValidDateFormat(String date) { + // 문자열 길이와 숫자 형식 검증 + if (date.length() != 8 || !date.matches("\\d{8}")) { + return false; + } + + // 날짜 형식 검증 + try { + LocalDate.parse(date, DateTimeFormatter.ofPattern("yyyyMMdd")); + return true; + } catch (DateTimeParseException e) { + return false; + } + } + + + 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 String getDateOfMade() { + return dateOfMade; + } + + public void setDateOfMade(String dateOfMade) { + this.dateOfMade = dateOfMade; + } + + public AuthMethod[] getAuthMethod() { + return authMethods; + } + + public void setAuthMethod(AuthMethod[] authMethods) { + this.authMethods = authMethods; + } + + public static int getObjectNo() { + return objectNo; + } + + public static void setObjectNo(int objectNo) { + Electronic.objectNo = objectNo; + } + + @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) && Arrays.equals(authMethods, that.authMethods); + } + + @Override + public int hashCode() { + int result = Objects.hash(productNo, modelName, companyName, dateOfMade); + result = 31 * result + Arrays.hashCode(authMethods); + return result; + } + + @Override + public String toString() { + return "{" + + "productNo='" + productNo + '\'' + + ", modelName='" + modelName + '\'' + + ", companyName=" + companyName + + ", dateOfMade='" + dateOfMade + '\'' + + ", authMethod=" + Arrays.toString(authMethods) + + '}'; + } +} diff --git a/me/day05/practice/practice01/Main.java b/me/day05/practice/practice01/Main.java new file mode 100644 index 0000000..00403cd --- /dev/null +++ b/me/day05/practice/practice01/Main.java @@ -0,0 +1,15 @@ +package me.day05.practice.practice01; + + + +public class Main { + public static void main(String[] args) { + Electronic a1 = new Electronic("javis", Company.SAMSUNG, "", new AuthMethod[]{AuthMethod.PIN}); + System.out.println(a1.toString()); + Electronic a2 = new Electronic("havis", Company.SAMSUNG, "20000121", new AuthMethod[]{AuthMethod.PIN}); + System.out.println(a2.toString()); + + User m1 = new User("fallen", "page7", "010-2222-3333", "ast@gmail.com", "060220", new String[]{"hell"}); + System.out.println(m1.toString()); + } +} diff --git a/me/day05/practice/practice01/User.java b/me/day05/practice/practice01/User.java new file mode 100644 index 0000000..7cd5b80 --- /dev/null +++ b/me/day05/practice/practice01/User.java @@ -0,0 +1,119 @@ +package me.day05.practice.practice01; + +import java.time.LocalDate; +import java.time.LocalDateTime; +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 String[] electronicDevices; //사용중인 전자제품들, 배열로 정의 + private LocalDateTime registerTime; //회원정보가 등록된 시스템시간, 생성시 시스템시간 자동설정. + + public User() { + this.registerTime = LocalDateTime.now(); + } + //기본생성자, 객체생성시 시스템시간 자동설정 + + public User(String userId, String userPassword, String userPhoneNumber, String userEmail, String userBirthDate, String[] electronicDevices) { + this.userId = userId; + this.userPassword = userPassword; + this.userPhoneNumber = userPhoneNumber; + this.userEmail = userEmail; + this.userBirthDate = userBirthDate; + this.electronicDevices = electronicDevices; + this.registerTime = LocalDateTime.now(); + + + + + } //7개의 멤버변수필드를 인자로 가지는 생성자 + + 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 String[] getElectronicDevices() { + return electronicDevices; + } + + public void setElectronicDevices(String[] 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 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; + } + + @Override + public String toString() { + return "{" + + "userId='" + userId + '\'' + + ", userPassword='" + userPassword + '\'' + + ", userPhoneNumber='" + userPhoneNumber + '\'' + + ", userEmail='" + userEmail + '\'' + + ", userBirthDate='" + userBirthDate + '\'' + + ", electronicDevices=" + Arrays.toString(electronicDevices) + + ", registerTime=" + registerTime + + '}'; + } +} diff --git a/me/day05/practice/practice02/Users.java b/me/day05/practice/practice02/Users.java new file mode 100644 index 0000000..6fe8863 --- /dev/null +++ b/me/day05/practice/practice02/Users.java @@ -0,0 +1,76 @@ +package me.day05.practice.practice02; + +import me.day05.practice.practice01.User; + +import java.util.Arrays; + +public class Users { + private User[] userList; + + private Users() { + + } + + public User[] getUserList() { + return userList; + } + + //1. Users클래스의 객체를 싱글톤으로 생성하는 함수를 작성하시오. + private static Users instance = new Users(); + + public static Users getInstance() { + if (instance == null) { + instance = new Users(); + } + return instance; + } + + public User findByUserId(String userId) { + return Arrays.stream(userList) + .filter(user -> user.getUserId().equals(userId)) + .findFirst() + .orElse(null); + } + + + + //3. 인자로 주어진 회원 정보를 깊은 복사 (deepCopy) 하는 함수를 작성하시오. + public User copy(User user) { + User copyuser = new User(user.getUserId(), + user.getUserEmail(), + user.getUserPassword(), + user.getUserBirthDate(), + user.getUserPhoneNumber(), + user.getElectronicDevices()); + return copyuser; + } + + + public void setUserList(User[] userList) { + this.userList = userList; + } + + public Users(User[] userList) { + this.userList = userList; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Users users = (Users) o; + return Arrays.equals(userList, users.userList); + } + + @Override + public int hashCode() { + return Arrays.hashCode(userList); + } + + @Override + public String toString() { + return "{" + + "userList=" + Arrays.toString(userList) + + '}'; + } +} diff --git a/me/day05/practice/practice03/Electronics.java b/me/day05/practice/practice03/Electronics.java new file mode 100644 index 0000000..39c7624 --- /dev/null +++ b/me/day05/practice/practice03/Electronics.java @@ -0,0 +1,91 @@ +package me.day05.practice.practice03; +import me.day05.practice.practice01.AuthMethod; +import me.day05.practice.practice01.Company; +import me.day05.practice.practice01.Electronic; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class Electronics { + private Electronic[] electronicList; + + //1.Electronics 클래스의 객체를 싱글톤으로 생성하는 함수를 작성하시오. + private static Electronics instance; + private Electronics() {}; + + public static Electronics getInstance() { + if(instance == null) { + instance = new Electronics(); + } + return instance; + } + + //2.전자제품 일련번호 productNo를 통해 인자로 주어진 일련번호에 해당하는 전자제품을 반환하는 함수를 작성하시오. + public Electronic findByProductNo(String productNo) { + return Arrays.stream(electronicList) + .filter(electronic -> electronic.getProductNo().equals(productNo)) + .findFirst() + .orElse(null); + } + + + //3.전자제품들 중 인자로 주어진 제조 회사를 찾아서 하나의 배열에 반환하는 함수를 작성하시오. + public Electronic[] groupByCompanyName(Company company) { + List groupCompanyList = new ArrayList<>(); + for (Electronic electronic : electronicList) { + if (electronic.getCompanyName().equals(company)) { + groupCompanyList.add(electronic); + } + + } + return groupCompanyList.toArray(new Electronic[groupCompanyList.size()]); + } + + + + + //4. 전자제품들 중 인자로 주어진 인증 방법을 찾아서 하나의 배열에 반환하는 함수를 작성하시오. + public Electronic[] groupByAuthMethod(AuthMethod authMethod){ + List groupAuthList = new ArrayList<>(); + for (Electronic electronic : electronicList) { + for (AuthMethod electronicAuthMethod : electronic.getAuthMethod()) { + if (electronicAuthMethod.equals(authMethod)) { + groupAuthList.add(electronic); + break; + } + } + } + return groupAuthList.toArray(new Electronic[0]); + } + + + + public Electronic[] getElectronicList() { + return electronicList; + } + + public void setElectronicList(Electronic[] electronicList) { + this.electronicList = electronicList; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Electronics that = (Electronics) o; + return Arrays.equals(electronicList, that.electronicList); + } + + @Override + public int hashCode() { + return Arrays.hashCode(electronicList); + } + + @Override + public String toString() { + return "{" + + "electronicList=" + Arrays.toString(electronicList) + + '}'; + } +} diff --git a/out/production/KDTBE5_Java_Assignment3/.gitignore b/out/production/KDTBE5_Java_Assignment3/.gitignore new file mode 100644 index 0000000..1847a1b --- /dev/null +++ b/out/production/KDTBE5_Java_Assignment3/.gitignore @@ -0,0 +1,30 @@ +# Created by https://www.toptal.com/developers/gitignore/api/java +# Edit at https://www.toptal.com/developers/gitignore?templates=java + +### Java ### +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +replay_pid* + +# End of https://www.toptal.com/developers/gitignore/api/java \ No newline at end of file diff --git a/out/production/KDTBE5_Java_Assignment3/.idea/.gitignore b/out/production/KDTBE5_Java_Assignment3/.idea/.gitignore new file mode 100644 index 0000000..60eee04 --- /dev/null +++ b/out/production/KDTBE5_Java_Assignment3/.idea/.gitignore @@ -0,0 +1,34 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +### Java template +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +replay_pid* + diff --git a/out/production/KDTBE5_Java_Assignment3/.idea/KDTBE5_Java_Assignment3.iml b/out/production/KDTBE5_Java_Assignment3/.idea/KDTBE5_Java_Assignment3.iml new file mode 100644 index 0000000..b107a2d --- /dev/null +++ b/out/production/KDTBE5_Java_Assignment3/.idea/KDTBE5_Java_Assignment3.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/out/production/KDTBE5_Java_Assignment3/.idea/discord.xml b/out/production/KDTBE5_Java_Assignment3/.idea/discord.xml new file mode 100644 index 0000000..30bab2a --- /dev/null +++ b/out/production/KDTBE5_Java_Assignment3/.idea/discord.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/out/production/KDTBE5_Java_Assignment3/.idea/misc.xml b/out/production/KDTBE5_Java_Assignment3/.idea/misc.xml new file mode 100644 index 0000000..4458232 --- /dev/null +++ b/out/production/KDTBE5_Java_Assignment3/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/out/production/KDTBE5_Java_Assignment3/.idea/modules.xml b/out/production/KDTBE5_Java_Assignment3/.idea/modules.xml new file mode 100644 index 0000000..12e7bfa --- /dev/null +++ b/out/production/KDTBE5_Java_Assignment3/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/out/production/KDTBE5_Java_Assignment3/.idea/uiDesigner.xml b/out/production/KDTBE5_Java_Assignment3/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/out/production/KDTBE5_Java_Assignment3/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/out/production/KDTBE5_Java_Assignment3/.idea/vcs.xml b/out/production/KDTBE5_Java_Assignment3/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/out/production/KDTBE5_Java_Assignment3/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/out/production/KDTBE5_Java_Assignment3/README.md b/out/production/KDTBE5_Java_Assignment3/README.md new file mode 100644 index 0000000..0dff600 --- /dev/null +++ b/out/production/KDTBE5_Java_Assignment3/README.md @@ -0,0 +1,26 @@ +
+ +### 자바 과제3

+> 제출자 - 최은빈 +> 출시일 - 23.04.11. +> 제출일 - 23.04.17. + +- [Day5](https://echoiing-fastcampus.notion.site/3-49385516d4e7430da0bfb85012f22cd9) 문제를 풀어서 제출하시오. + +- 파일 이름 작성법 + - ````me.day05.practice```` 패키지 생성 + - ````Practice01, Practice02, Practice03, ...```` 클래스 생성하여 작성 +- 제출방법 + - 본인의 이름으로 ````branch````를 생성하여 ````push````후 ````pull request```` 작성 + - 예시 + - branch 이름 - ````FirstNameLastName```` + - commit 메시지 - ````Java Assignment3 upload by FirstNameLastName```` + - pull request는 본인이 하고 싶은 말이나 질문을 적어주세요. + - ````코드리뷰 빡세게 부탁드립니다.```` ````클린한 코드인지 봐주세요.```` ````이 코드의 조금 더 나은 방법이 있을까요.```` + - ````~~번 문제 풀지 못했습니다.```` ````~~번 문제 풀이 방법을 알려주시면 감사하겠습니다.```` + - ````결과는 나왔는데 맞는지 모르겠습니다.```` +- 주의사항 + - 본인 ```branch``` -> ```main branch``` PR한 상태로 제출부탁드립니다. + - ```main branch```에 본인 ```branch```의 ```commit```을 ```merge``` 하지 마시기 바랍니다. + +