Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/Library-Management-System.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/libraries/KotlinJavaRuntime.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Answers/40230212031/src/com/Library/Admin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.Library;

public class Admin {
}
2 changes: 2 additions & 0 deletions Answers/40230212031/src/com/Library/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package com.Library;public class App {
}
53 changes: 53 additions & 0 deletions Answers/40230212031/src/com/Library/Book.java
Original file line number Diff line number Diff line change
@@ -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 یکتا به صورت تصادفی

}
}

4 changes: 4 additions & 0 deletions Answers/40230212031/src/com/Library/CLI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.Library;

public class CLI {
}
88 changes: 88 additions & 0 deletions Answers/40230212031/src/com/Library/Library.java
Original file line number Diff line number Diff line change
@@ -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<Book> booksList;
private List<User> userList;
private List<Rent> 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<Book> getBooks() {
return booksList;
}
public List<Book> getBooksList() {
List<Book> 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<User> 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 () {
}
}
}


4 changes: 4 additions & 0 deletions Answers/40230212031/src/com/Library/NormalUser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.Library;

public class NormalUser {
}
29 changes: 29 additions & 0 deletions Answers/40230212031/src/com/Library/Rent.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
4 changes: 4 additions & 0 deletions Answers/40230212031/src/com/Library/User.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.Library;

public class User {
}
File renamed without changes.
Empty file added data/rentals.txt
Empty file.
Empty file added data/users.txt
Empty file.