Browse Source

Main.java

- borrowBook(User, Book) is added as a unified function that will
update and change all required data when a user attempts to borrow a
book
master
BinHong Lee 8 years ago
parent
commit
e41e28bff6
1 changed files with 19 additions and 1 deletions
  1. +19
    -1
      Main.java

+ 19
- 1
Main.java View File

@@ -1,6 +1,6 @@
/* /*
* Written by : Bin Hong Lee * Written by : Bin Hong Lee
* Last edited : 5/31/2016
* Last edited : 6/12/2016
*/ */


import java.util.Date; import java.util.Date;
@@ -17,6 +17,24 @@ class Main


} }


public static boolean borrowBook(User user, Book book)
{
User newUser = user;

if(book.getStatus() == "AVAILABLE" && newUser.status())
{
book.rent(calDueDate(10));
newUser.borrowNewBook(book.getId());

books.update(book);
users.update(user, newUser);

return true;
}

return false;
}

public static boolean returnBook(User user, Book book) public static boolean returnBook(User user, Book book)
{ {
User newUser = user; User newUser = user;


Loading…
Cancel
Save