You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.md 3.4 KiB

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