Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

index.md 3.5 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. # Documentations
  2. ## Table of Content
  3. - [Main](#main)
  4. - [Book](#book)
  5. - [Book Factory](#book-factory)
  6. - [User](#user)
  7. - [User Factory](#user-factory)
  8. # Main
  9. ## Functions
  10. | Return | Method | Description |
  11. |:-------|:-------|:------------|
  12. | boolean | borrowBook(User user, Book book) | Return if the borrow of the book on both `BookFactory` and `UserFactory` is successful
  13. | boolean | returnBook(User user, Book book) | Return if the return of the book on both `BookFactory` and `UserFactory` is successful
  14. | int[] | calDueDate(int days) | Calculate the due date from the current date according to user's permission
  15. | int[] | currentDay() | Returns the current date in an array form |
  16. # Book
  17. ## Constructors
  18. | Method | Description |
  19. |:-------|:------------|
  20. | Book(int id) | Create a book with a specific id |
  21. | Book(String title, int id) | Create a book with specific id and title |
  22. ## Functions
  23. | Return | Method | Description |
  24. |:-------|:-------|:------------|
  25. | String | getTitle() | Returns the title of the book |
  26. | String | getStatus() | Returns the status of the book |
  27. | String | getId() | Returns the id of the book |
  28. | void | setTitle() | Set the title of the book |
  29. | boolean | rent(int[] dueDate) | Returns if the rent action is successful and set the due date to the given input |
  30. | void | returned() | Return the book |
  31. | double | overdueFine(int[] currentDay) | Calculate and return the amount of fine to be charged<br>(Fine rate is 0.25 per day; Max fine is 5) |
  32. # Book Factory
  33. ## Constructors
  34. | Method | Description |
  35. |:-------|:------------|
  36. | BookFactory() | Creates an empty BookFactory |
  37. ## Functions
  38. | Return | Method | Description |
  39. |:-------|:-------|:------------|
  40. | Book | newBook(String title) | Creates a new Book with the given title and returns it |
  41. | Book | getBook(int index) | Returns the book of the given index if it exist, else throw null pointer exception |
  42. | Book | getBook(String title) | Returns the book of the given title if it exist, else throw null pointer exception |
  43. | void | update(Book newbook) | Replaces the existing book of the same id with this new one |
  44. # User
  45. ## Constructors
  46. | Method | Description |
  47. |:-------|:------------|
  48. | User(String name, int id, int limit) | Create a new User with given name, id and limit |
  49. ## Functions
  50. | Return | Method | Description |
  51. |:-------|:-------|:------------|
  52. | String | getName() | Returns the name of the user |
  53. | int | getId() | Returns id of the user |
  54. | void | setName() | Set the name of the user |
  55. | boolean | status() | Check if the user reached the limit of amount of books the user can borrow |
  56. | List<Integer> | bookStatus() | Return a list consisting of book ids for all the books rented by the user |
  57. | boolean | borrowNewBook(int id) | Check if the user status if true then add the id to the list of the books borrowed by the user |
  58. | boolean | returnBook(int id) | Check if the book is borrowed by the user then remove it from the list |
  59. # User Factory
  60. ## Constructors
  61. | Method | Description |
  62. |:-------|:------------|
  63. | UserFactory() | Creates a new empty factory |
  64. ## Functions
  65. | Return | Method | Description |
  66. |:-------|:-------|:------------|
  67. | User | newUser(String name, int limit) | Creates a new user and returns the created user |
  68. | User | getUser(String name) | Gets the user with the given name from the factory |
  69. | User | getUser(int index) | Gets the user with the given id from the factory |
  70. | void | update(User oldUser, User newUser) | Update by replacing the existing user with the new one |