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/Library-Management-System.iml b/.idea/Library-Management-System.iml new file mode 100644 index 0000000..776401a --- /dev/null +++ b/.idea/Library-Management-System.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..e0236b2 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..cd83845 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/libraries/KotlinJavaRuntime.xml b/.idea/libraries/KotlinJavaRuntime.xml new file mode 100644 index 0000000..d2eaa8c --- /dev/null +++ b/.idea/libraries/KotlinJavaRuntime.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..07115cd --- /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..2e1b46d --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ 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/Answers/40230212031/src/com/Library/Admin.java b/Answers/40230212031/src/com/Library/Admin.java new file mode 100644 index 0000000..02be5c1 --- /dev/null +++ b/Answers/40230212031/src/com/Library/Admin.java @@ -0,0 +1,4 @@ +package com.Library; + +public class Admin { +} diff --git a/Answers/40230212031/src/com/Library/App.java b/Answers/40230212031/src/com/Library/App.java new file mode 100644 index 0000000..b021daf --- /dev/null +++ b/Answers/40230212031/src/com/Library/App.java @@ -0,0 +1,2 @@ +package com.Library;public class App { +} diff --git a/Answers/40230212031/src/com/Library/Book.java b/Answers/40230212031/src/com/Library/Book.java new file mode 100644 index 0000000..6187a82 --- /dev/null +++ b/Answers/40230212031/src/com/Library/Book.java @@ -0,0 +1,53 @@ +package com.Library; +import java.util.UUID; + +public class Book { + private String bookID; + private String title; + private String author; + private boolean exist; + private String description; + public Book(){}//برای ساخت object بدون نیاز به اطلاعات قبلی + public Book(String title,String author,String description){ + this.title = title; + this.author = author; + this.exist = true; + this.description = description; + this.bookID = String.valueOf(BookID());// این متد مقدار را به رشته تبدیل میکند + } +// برای گرفتن مقادیر ازgetter +// برای تغیر ویژگی ها از setter +public String getBookID(){ + return bookID; +} +public String getTitle(){ + return title; +} + public String getAuthor() { + return author; + } + public String getDescription() { + return description; + } + public void setTitle(String title) { + this.title = title; + } + public void setAuthor(String author) { + this.author = author; + } + public boolean isExist() { + return exist; + } + + public void setExist(boolean exist) { + this.exist = exist; + } + public void setDescription(String description) { + this.description = description; + } + public UUID BookID() { + return UUID.randomUUID(); // تولید یک ID یکتا به صورت تصادفی + + } +} + diff --git a/Answers/40230212031/src/com/Library/CLI.java b/Answers/40230212031/src/com/Library/CLI.java new file mode 100644 index 0000000..7463a61 --- /dev/null +++ b/Answers/40230212031/src/com/Library/CLI.java @@ -0,0 +1,4 @@ +package com.Library; + +public class CLI { +} diff --git a/Answers/40230212031/src/com/Library/Library.java b/Answers/40230212031/src/com/Library/Library.java new file mode 100644 index 0000000..d51d91b --- /dev/null +++ b/Answers/40230212031/src/com/Library/Library.java @@ -0,0 +1,88 @@ +package com.Library; + +import java.util.ArrayList; +import java.util.List; +import java.time.LocalDate; +public class Library { + private static final String BOOKS_FILE = "data/books.xml"; + private static final String USERS_FILE = "data/users.xml"; + private static final String RENTALS_FILE = "data/rentals.xml"; + + private String name; + private int vacancy; + private String businessHours; + + private List booksList; + private List userList; + private List rentalList; + + public Library(String name, int vacancy, String businessHours) { + this.name = name; + this.vacancy = vacancy; + this.businessHours = businessHours; + this.booksList = new ArrayList<>(); + this.userList = new ArrayList<>(); + this.rentalList = new ArrayList<>(); + + } + + public String getName() { + return name; + } + + public int getVacancy() { + return vacancy; + } + + public String getBusinessHours() { + return businessHours; + } + public void addBook(Book book) { + booksList.add(book); + saveBooks(); + } + public List getBooks() { + return booksList; + } + public List getBooksList() { + List libraryBook = new ArrayList<>(); + for (int i = 0; i < booksList.size(); i++) { + Book book = booksList.get(i); + if (book.isExist()) { + libraryBook.add(book); + } + } + return libraryBook; + } + //////////////////////////////////////////////////////////// + public void adduser(User user){ + userList.add(user); + saveUser(); + } + public List getUser(){ + return userList; + } + ////////////////////////////////////////////////////////////// + public void rentBook(Book book, User user) { + if (!book.isExist()) { + System.out.println("Sorry ^--^ : the book is currently not available for rental."); + return; + } else { + + String rentalDate = LocalDate.now().toString(); + Rent rent = new Rent(book, user, rentalDate); + rentalList.add(rent); + book.setExist(false); + + saveBooks(); + saveRentals(); + + System.out.println("Book rented successfully!"); + } + } + private void saveBooks () { + } + } +} + + diff --git a/Answers/40230212031/src/com/Library/NormalUser.java b/Answers/40230212031/src/com/Library/NormalUser.java new file mode 100644 index 0000000..9cb8869 --- /dev/null +++ b/Answers/40230212031/src/com/Library/NormalUser.java @@ -0,0 +1,4 @@ +package com.Library; + +public class NormalUser { +} diff --git a/Answers/40230212031/src/com/Library/Rent.java b/Answers/40230212031/src/com/Library/Rent.java new file mode 100644 index 0000000..8433384 --- /dev/null +++ b/Answers/40230212031/src/com/Library/Rent.java @@ -0,0 +1,29 @@ +package com.Library; + +public class Rent { + private Book book ; + private User user; + private int rentalId;//آیدی برای اجاره کتاب که تکراری نشود!!! + private String rentalDate; //مدت زمان rent + + private static int nextRentalID =1; // مقدار پیش فرض یا اولیه آیدی + public Rent(Book book, User user, String rentalDate) { + this.book = book; + this.user = user; + this.rentalId = nextRental; + nextRental++; + this.rentalDate = rentalDate; + } + public Book getBook(){ + return book; + } + public User getUser(){ + return rentalId; + } + public int getRentalId(){ + return rentalId; + } + public String getRentalDate() { + return rentalDate; + } + } diff --git a/Answers/40230212031/src/com/Library/User.java b/Answers/40230212031/src/com/Library/User.java new file mode 100644 index 0000000..0a3030e --- /dev/null +++ b/Answers/40230212031/src/com/Library/User.java @@ -0,0 +1,4 @@ +package com.Library; + +public class User { +} diff --git a/Answers/Add Your Projects Here.txt b/data/books.txt similarity index 100% rename from Answers/Add Your Projects Here.txt rename to data/books.txt diff --git a/data/rentals.txt b/data/rentals.txt new file mode 100644 index 0000000..e69de29 diff --git a/data/users.txt b/data/users.txt new file mode 100644 index 0000000..e69de29