diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/24_2_BE_Beginner_Week2_team2.iml b/.idea/24_2_BE_Beginner_Week2_team2.iml new file mode 100644 index 0000000..b107a2d --- /dev/null +++ b/.idea/24_2_BE_Beginner_Week2_team2.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..1b2d693 --- /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..d59629e --- /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/Book.java b/Book.java new file mode 100644 index 0000000..5bd06eb --- /dev/null +++ b/Book.java @@ -0,0 +1,58 @@ +import java.time.LocalDate; + +public class Book { + private String title; + private String author; + private String publisher; + private String ISBN; + private LocalDate publishDate; + private boolean isLoaned; //대출 여부 + private T loanedBy; //대출한 사용자 정보 + private LocalDate dueDate; //반납 예정일 + + //생성자 + public Book(String title, String author, String publisher, String ISBN, LocalDate publishDate) { + this.title = title; + this.author = author; + this.publisher = publisher; + this.ISBN = ISBN; + this.publishDate = publishDate; + this.isLoaned = false; + this.dueDate = null; + } + + //Getter,Setter + + public String getTitle() { + return title; + } + + public LocalDate getDueDate() { + return dueDate; + } + + public T getLoanedBy() { + return loanedBy; + } + + public void setLoanedBy(T loanedBy) { + this.loanedBy = loanedBy; + this.isLoaned = true; + } + + //책 정보 출력 + public void printBookInfo() { + System.out.println("Title: " + title); + System.out.println("Author: " + author); + System.out.println("Publisher: " + publisher); + System.out.println("ISBN: " + ISBN); + System.out.println("Published on: " + publishDate); + if (isLoaned) { + System.out.println("loaned to: " + loanedBy.toString()); + System.out.println("Due date: " + dueDate); + } else { + System.out.println("Available for loan."); + } + } +} + diff --git a/BookNotFoundException.java b/BookNotFoundException.java new file mode 100644 index 0000000..c4aa10c --- /dev/null +++ b/BookNotFoundException.java @@ -0,0 +1,6 @@ +public class BookNotFoundException extends Exception { + //생성자 + public BookNotFoundException(String msg) { + super(msg); + } +} diff --git a/Library.java b/Library.java new file mode 100644 index 0000000..207ba56 --- /dev/null +++ b/Library.java @@ -0,0 +1,108 @@ + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.*; + +public class Library { + // 변수 선언부 + private static final String address = "부산 남구 용소로 45"; + private String name; // 도서관 이름 + private List bookList; + private T userContainer; + + public Library(String name) { + this.name = name; + this.bookList = new ArrayList<>(); + } + + //BookNotFoundException 커스텀 예외 클래스에서 예외 처리하기 위한 메서드 작성 + public Optional findBook(String title) throws BookNotFoundException { + for(Book book : bookList){ // bookList에 생성된 Book 객체 순회. + if(book.getTitle().equals(title)) { + return Optional.of(book); + } + } + return Optional.empty(); //책 찾지 못했을 때 빈 optional 반환. + } + + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + LibraryController lc = new LibraryController(); + + public void showLibraryMemu() throws IOException { + + while(true) { + System.out.println("메뉴를 선택하세요."); + System.out.println("1. 사용자 등록"); + System.out.println("2. 사용자 탈퇴"); + System.out.println("3. 도서 대출"); + System.out.println("4. 도서 반납"); + System.out.println("5. 도서 추가"); + System.out.println("6. 도서 삭제"); + System.out.println("7. 끝내기"); + System.out.println("============================"); + System.out.print("사용할 메뉴 : "); + + int num = Integer.parseInt(br.readLine()); + + switch(num) { + case 1 : + + break; + case 2 : + + break; + case 3 : + + break; + case 4 : + + break; + case 5 : + bookAdd(); + break; + case 6 : + + break; + case 7 : + System.out.println("프로그램을 종료합니다."); + return; + default : + System.out.println("번호를 다시 입력해주세요."); + } + + } + } + private Book bookAdd() throws IOException { + System.out.println("도서 추가"); + System.out.print("도서명 : "); + String title = br.readLine(); + System.out.print("작가명 : "); + String author = br.readLine(); + //System.out.print("카테고리 : "); + //String category = br.readLine(); + System.out.print("출판사 : "); + String publisher = br.readLine(); + System.out.print("ISBN : "); + String ISBN = br.readLine(); + System.out.print("출판일 : "); + String publishDateString = br.readLine(); + LocalDate publishDate = LocalDate.parse(publishDateString, DateTimeFormatter.ofPattern("yyyyMMdd")); + System.out.print("가격 : "); + int price = Integer.parseInt(br.readLine()); + + // Book 클래스 생성자를 사용해 책 객체 생성 + Book book = new Book(title, author, publisher, ISBN, publishDate); + bookList.add(book); + return book; + } + + public static void main(String[] args) throws IOException { + Library pknuL = new Library("중앙도서관"); + pknuL.showLibraryMemu(); + + } +} + diff --git a/LibraryController.java b/LibraryController.java new file mode 100644 index 0000000..fdeecb8 --- /dev/null +++ b/LibraryController.java @@ -0,0 +1,3 @@ +public class LibraryController { + +} diff --git a/LibrarySystem.java b/LibrarySystem.java new file mode 100644 index 0000000..38e12c6 --- /dev/null +++ b/LibrarySystem.java @@ -0,0 +1,13 @@ +import java.awt.print.Book; +import java.util.Optional; + +interface LibrarySystem{ + void addUser(int userId, String name); + void removeUser(int userId); + void addBook(Book book, int userId); + void borrowBook(int userId, String bookTitle); + void returnBook(int userId, String bookTitle); + + Optional findBook(String title); + Optional findUser(int userId); +} diff --git a/Pair.java b/Pair.java new file mode 100644 index 0000000..498e764 --- /dev/null +++ b/Pair.java @@ -0,0 +1,15 @@ +public class Pair { + private T x; + private T y; + public Pair(T x, T y) { + this.x = x; + this.y = y; + } + + public T getX() { + return x; + } + public T getY() { + return y; + } +} \ No newline at end of file diff --git a/Role.java b/Role.java new file mode 100644 index 0000000..4ddbf8e --- /dev/null +++ b/Role.java @@ -0,0 +1,16 @@ +public enum Role { + STUDENT(0), + PROFESSOR(1), + STAFF(2), + ADMIN(3); + + private final int value; + + Role(int value) { + this.value = value; + } + + public String getRole(int value) { + return Role.values()[value].toString(); + } +} \ No newline at end of file diff --git a/User.java b/User.java new file mode 100644 index 0000000..d3d998e --- /dev/null +++ b/User.java @@ -0,0 +1,45 @@ +import java.util.Queue; + +public class User { + private final String id; + private final String name; + private final String role; + private Queue books; + + /* + * At first, User object had planned to implemented by + * pulling out from somewhere it exists with recognized by id. + * But, User object doesn't come out from DB or somewhere. + * We cannot pull the value of it, which is name, role, out. + * Because it has NO resource of pulling out from. + * And I decided make dummy data of user. + * Therefore, name, role, should have assigned when it generated. + * -- Commented by Jae Min -- + * */ + public User(String id, String name, String role, Queue books) { + this.id = id; + this.name = name; + this.role = role; + this.books = books; + } + + public String getId() { + return id; + } + + public String getName() { + return name; + } + + public String getRole() { + return role; + } + + public Queue getBook() { + return books; + } + + public void returnBook(T book) { + + } +} \ No newline at end of file diff --git a/UserContainer.java b/UserContainer.java new file mode 100644 index 0000000..fd9ac75 --- /dev/null +++ b/UserContainer.java @@ -0,0 +1,20 @@ +import java.util.HashMap; + +public class UserContainer{ + User[] users; + HashMap userMap; + + public Pair getInfo(String id) { + User user = userMap.get(id); + return new Pair<>(user.getName(), user.getRole()); + } + + public void addUser(User user) { + userMap.put(user.getId(), user); + } + + public void removeUser(String id) { + userMap.remove(id); + } + +} \ No newline at end of file diff --git a/UserNotFoundException.java b/UserNotFoundException.java new file mode 100644 index 0000000..b18139c --- /dev/null +++ b/UserNotFoundException.java @@ -0,0 +1,6 @@ +public class UserNotFoundException extends Exception { + //생성자 + public UserNotFoundException(String msg) { + super(msg); + } +} diff --git a/Users.java b/Users.java new file mode 100644 index 0000000..7734d1a --- /dev/null +++ b/Users.java @@ -0,0 +1,22 @@ +import java.util.HashMap; +import java.util.Map; + +public class Users { + private static Map userList = new HashMap<>(); + + // 회원 등록 + public static void addUser(int userId, String name) { + userList.put(userId, name); + } + public static void removeUser(int userId) { + if(userList.remove(userId) != null) { + System.out.println("회원 탈퇴 완료"); + } else { + //throw new UserNotFoundException("회원 ID 존재 하지 않음"); + } + } + public static boolean checkExistUser(int userId) { + return userList.containsKey(userId); + } + +} diff --git a/out/production/24_2_BE_Beginner_Week2_team2/.idea/.gitignore b/out/production/24_2_BE_Beginner_Week2_team2/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/out/production/24_2_BE_Beginner_Week2_team2/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/out/production/24_2_BE_Beginner_Week2_team2/.idea/24_2_BE_Beginner_Week2_team2.iml b/out/production/24_2_BE_Beginner_Week2_team2/.idea/24_2_BE_Beginner_Week2_team2.iml new file mode 100644 index 0000000..b107a2d --- /dev/null +++ b/out/production/24_2_BE_Beginner_Week2_team2/.idea/24_2_BE_Beginner_Week2_team2.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/out/production/24_2_BE_Beginner_Week2_team2/.idea/misc.xml b/out/production/24_2_BE_Beginner_Week2_team2/.idea/misc.xml new file mode 100644 index 0000000..1b2d693 --- /dev/null +++ b/out/production/24_2_BE_Beginner_Week2_team2/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/out/production/24_2_BE_Beginner_Week2_team2/.idea/modules.xml b/out/production/24_2_BE_Beginner_Week2_team2/.idea/modules.xml new file mode 100644 index 0000000..d59629e --- /dev/null +++ b/out/production/24_2_BE_Beginner_Week2_team2/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/out/production/24_2_BE_Beginner_Week2_team2/.idea/vcs.xml b/out/production/24_2_BE_Beginner_Week2_team2/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/out/production/24_2_BE_Beginner_Week2_team2/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/out/production/24_2_BE_Beginner_Week2_team2/Book.class b/out/production/24_2_BE_Beginner_Week2_team2/Book.class new file mode 100644 index 0000000..7e1f666 Binary files /dev/null and b/out/production/24_2_BE_Beginner_Week2_team2/Book.class differ diff --git a/out/production/24_2_BE_Beginner_Week2_team2/BookNotFoundException.class b/out/production/24_2_BE_Beginner_Week2_team2/BookNotFoundException.class new file mode 100644 index 0000000..cd458d6 Binary files /dev/null and b/out/production/24_2_BE_Beginner_Week2_team2/BookNotFoundException.class differ diff --git a/out/production/24_2_BE_Beginner_Week2_team2/Library.class b/out/production/24_2_BE_Beginner_Week2_team2/Library.class new file mode 100644 index 0000000..1d48c90 Binary files /dev/null and b/out/production/24_2_BE_Beginner_Week2_team2/Library.class differ diff --git a/out/production/24_2_BE_Beginner_Week2_team2/LibrarySystem.class b/out/production/24_2_BE_Beginner_Week2_team2/LibrarySystem.class new file mode 100644 index 0000000..11191d2 Binary files /dev/null and b/out/production/24_2_BE_Beginner_Week2_team2/LibrarySystem.class differ diff --git a/out/production/24_2_BE_Beginner_Week2_team2/README.md b/out/production/24_2_BE_Beginner_Week2_team2/README.md new file mode 100644 index 0000000..ee7ab07 --- /dev/null +++ b/out/production/24_2_BE_Beginner_Week2_team2/README.md @@ -0,0 +1,70 @@ +## **🌟과제 개요** + +--- + +2주차 과제는 팀 프로젝트로 진행되며, 각 팀원은 **“최소 하나의 클래스”**를 설계하고 구현하는 것이 목표입니다. 각자의 클래스는 다른 팀원의 클래스와 **“조합”** 또는 **“상속”**을 통해 상호작용해야 합니다. + +자바의 객체지향 개념을 기반으로 팀 내에서 협력하여 프로젝트를 완성해주시면 됩니다. + +**📅 제출 기한**: 24일(화) 오전(12:00)까지 + +## **📝 과제 방식** + +--- + +1. 팀 내에서 **공통점, 공통 관심사를 알아보고, 관련하여 주제를 선택**한다. + - 공통 관심사가 도저히 없다면 팀내에서 원하는 주제를 정해도 됩니다! +2. 각 팀은 아래의 **“요구사항”에 맞게 자바 클래스들을 설계하고 구현**한다. + - 팀 내에서 역할을 잘 분배하여 프로젝트를 완성해주세요. +3. **24일(화) 오전까지 프로젝트를 깃허브에 업로드**하며, **24일 19시 프로젝트에 대해 발표**를 진행한다. + - 발표 자료는 자유이나 필수는 아닙니다. + - 코드 설명과 함께, 회의, 개발 과정이나 어려웠던 점 등 자유롭게 공유해주세요. +4. 발표 후 각 팀은 **다른 팀의 레포지토리에 코드 리뷰**를 남긴다. + - 궁금한점이나, 1주차에 받은 질문 중 스스로 공부한 부분을 질문으로 남겨도 괜찮습니다! + +## **🛠️요구사항** + +--- + +- 각 팀원은 **최소 하나의 클래스를 설계 및 구현**해야 합니다. + + + +- **팀 내 최소 1번은 다음의 자바 요소를 사용**해야합니다.(모두가 구현할 필요는 없습니다) + + + +- **깃허브 관련 요구사항** + + \ No newline at end of file diff --git a/out/production/24_2_BE_Beginner_Week2_team2/UserNotFoundException.class b/out/production/24_2_BE_Beginner_Week2_team2/UserNotFoundException.class new file mode 100644 index 0000000..4587f91 Binary files /dev/null and b/out/production/24_2_BE_Beginner_Week2_team2/UserNotFoundException.class differ diff --git a/out/production/24_2_BE_Beginner_Week2_team2/Users.class b/out/production/24_2_BE_Beginner_Week2_team2/Users.class new file mode 100644 index 0000000..c1ec60b Binary files /dev/null and b/out/production/24_2_BE_Beginner_Week2_team2/Users.class differ