From 65c9bec312d7bac3ff410dd9ad791611b9e6ed63 Mon Sep 17 00:00:00 2001 From: BinHong Lee Date: Sun, 4 Jun 2017 20:15:06 -0700 Subject: [PATCH] Documentations are now all in javadocs (through Maven Apache) --- docs/_config.yml | 2 - docs/allclasses-frame.html | 33 ++ docs/allclasses-noframe.html | 33 ++ docs/constant-values.html | 124 ++++ docs/deprecated-list.html | 124 ++++ docs/help-doc.html | 225 ++++++++ docs/index-all.html | 507 +++++++++++++++++ docs/index.html | 73 +++ docs/index.md | 95 ---- docs/libsys/Book.html | 478 ++++++++++++++++ docs/libsys/BookFactory.html | 408 +++++++++++++ docs/libsys/EditBookDialog.html | 465 +++++++++++++++ docs/libsys/EditUserDialog.html | 488 ++++++++++++++++ docs/libsys/Main.html | 278 +++++++++ docs/libsys/MainGUI.html | 408 +++++++++++++ docs/libsys/NewBookDialog.html | 484 ++++++++++++++++ docs/libsys/NewUserDialog.html | 484 ++++++++++++++++ docs/libsys/RentDialog.html | 445 +++++++++++++++ docs/libsys/ReturnDialog.html | 448 +++++++++++++++ docs/libsys/Settings.html | 405 +++++++++++++ docs/libsys/SettingsDialog.html | 507 +++++++++++++++++ docs/libsys/User.html | 483 ++++++++++++++++ docs/libsys/UserFactory.html | 408 +++++++++++++ docs/libsys/class-use/Book.html | 195 +++++++ docs/libsys/class-use/BookFactory.html | 152 +++++ docs/libsys/class-use/EditBookDialog.html | 124 ++++ docs/libsys/class-use/EditUserDialog.html | 124 ++++ docs/libsys/class-use/Main.html | 124 ++++ docs/libsys/class-use/MainGUI.html | 124 ++++ docs/libsys/class-use/NewBookDialog.html | 124 ++++ docs/libsys/class-use/NewUserDialog.html | 124 ++++ docs/libsys/class-use/RentDialog.html | 124 ++++ docs/libsys/class-use/ReturnDialog.html | 124 ++++ docs/libsys/class-use/Settings.html | 157 +++++ docs/libsys/class-use/SettingsDialog.html | 124 ++++ docs/libsys/class-use/User.html | 196 +++++++ docs/libsys/class-use/UserFactory.html | 124 ++++ docs/libsys/package-frame.html | 34 ++ docs/libsys/package-summary.html | 194 +++++++ docs/libsys/package-tree.html | 174 ++++++ docs/libsys/package-use.html | 151 +++++ docs/overview-tree.html | 178 ++++++ docs/package-list | 1 + docs/script.js | 30 + docs/serialized-form.html | 664 ++++++++++++++++++++++ docs/stylesheet.css | 574 +++++++++++++++++++ src/main/java/libsys/Book.java | 64 ++- src/main/java/libsys/BookFactory.java | 59 +- src/main/java/libsys/EditBookDialog.java | 26 +- src/main/java/libsys/EditUserDialog.java | 37 +- src/main/java/libsys/Handler.java | 33 +- src/main/java/libsys/Main.java | 8 +- src/main/java/libsys/MainGUI.java | 24 +- src/main/java/libsys/NewBookDialog.java | 72 +-- src/main/java/libsys/NewUserDialog.java | 66 +-- src/main/java/libsys/RentDialog.java | 75 +-- src/main/java/libsys/ReturnDialog.java | 82 +-- src/main/java/libsys/Settings.java | 54 +- src/main/java/libsys/SettingsDialog.java | 94 ++- src/main/java/libsys/User.java | 55 +- src/main/java/libsys/UserFactory.java | 82 ++- 61 files changed, 11731 insertions(+), 445 deletions(-) delete mode 100644 docs/_config.yml create mode 100644 docs/allclasses-frame.html create mode 100644 docs/allclasses-noframe.html create mode 100644 docs/constant-values.html create mode 100644 docs/deprecated-list.html create mode 100644 docs/help-doc.html create mode 100644 docs/index-all.html create mode 100644 docs/index.html delete mode 100644 docs/index.md create mode 100644 docs/libsys/Book.html create mode 100644 docs/libsys/BookFactory.html create mode 100644 docs/libsys/EditBookDialog.html create mode 100644 docs/libsys/EditUserDialog.html create mode 100644 docs/libsys/Main.html create mode 100644 docs/libsys/MainGUI.html create mode 100644 docs/libsys/NewBookDialog.html create mode 100644 docs/libsys/NewUserDialog.html create mode 100644 docs/libsys/RentDialog.html create mode 100644 docs/libsys/ReturnDialog.html create mode 100644 docs/libsys/Settings.html create mode 100644 docs/libsys/SettingsDialog.html create mode 100644 docs/libsys/User.html create mode 100644 docs/libsys/UserFactory.html create mode 100644 docs/libsys/class-use/Book.html create mode 100644 docs/libsys/class-use/BookFactory.html create mode 100644 docs/libsys/class-use/EditBookDialog.html create mode 100644 docs/libsys/class-use/EditUserDialog.html create mode 100644 docs/libsys/class-use/Main.html create mode 100644 docs/libsys/class-use/MainGUI.html create mode 100644 docs/libsys/class-use/NewBookDialog.html create mode 100644 docs/libsys/class-use/NewUserDialog.html create mode 100644 docs/libsys/class-use/RentDialog.html create mode 100644 docs/libsys/class-use/ReturnDialog.html create mode 100644 docs/libsys/class-use/Settings.html create mode 100644 docs/libsys/class-use/SettingsDialog.html create mode 100644 docs/libsys/class-use/User.html create mode 100644 docs/libsys/class-use/UserFactory.html create mode 100644 docs/libsys/package-frame.html create mode 100644 docs/libsys/package-summary.html create mode 100644 docs/libsys/package-tree.html create mode 100644 docs/libsys/package-use.html create mode 100644 docs/overview-tree.html create mode 100644 docs/package-list create mode 100644 docs/script.js create mode 100644 docs/serialized-form.html create mode 100644 docs/stylesheet.css diff --git a/docs/_config.yml b/docs/_config.yml deleted file mode 100644 index 22b43ad..0000000 --- a/docs/_config.yml +++ /dev/null @@ -1,2 +0,0 @@ -title: Library System -theme: jekyll-theme-dinky diff --git a/docs/allclasses-frame.html b/docs/allclasses-frame.html new file mode 100644 index 0000000..0194ef3 --- /dev/null +++ b/docs/allclasses-frame.html @@ -0,0 +1,33 @@ + + + + + + +All Classes (LibrarySystem 1.0 API) + + + + + +

All Classes

+
+ +
+ + diff --git a/docs/allclasses-noframe.html b/docs/allclasses-noframe.html new file mode 100644 index 0000000..40e27d3 --- /dev/null +++ b/docs/allclasses-noframe.html @@ -0,0 +1,33 @@ + + + + + + +All Classes (LibrarySystem 1.0 API) + + + + + +

All Classes

+
+ +
+ + diff --git a/docs/constant-values.html b/docs/constant-values.html new file mode 100644 index 0000000..17f39a6 --- /dev/null +++ b/docs/constant-values.html @@ -0,0 +1,124 @@ + + + + + + +Constant Field Values (LibrarySystem 1.0 API) + + + + + + + + +
+ + + + + + + +
+ + +
+

Constant Field Values

+

Contents

+
+ +
+ + + + + + + +
+ + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/deprecated-list.html b/docs/deprecated-list.html new file mode 100644 index 0000000..20c676b --- /dev/null +++ b/docs/deprecated-list.html @@ -0,0 +1,124 @@ + + + + + + +Deprecated List (LibrarySystem 1.0 API) + + + + + + + + +
+ + + + + + + +
+ + +
+

Deprecated API

+

Contents

+
+ +
+ + + + + + + +
+ + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/help-doc.html b/docs/help-doc.html new file mode 100644 index 0000000..4874984 --- /dev/null +++ b/docs/help-doc.html @@ -0,0 +1,225 @@ + + + + + + +API Help (LibrarySystem 1.0 API) + + + + + + + + +
+ + + + + + + +
+ + +
+

How This API Document Is Organized

+
This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
+
+
+ +This help file applies to API documentation generated using the standard doclet.
+ +
+ + + + + + + +
+ + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/index-all.html b/docs/index-all.html new file mode 100644 index 0000000..9629c63 --- /dev/null +++ b/docs/index-all.html @@ -0,0 +1,507 @@ + + + + + + +Index (LibrarySystem 1.0 API) + + + + + + + + +
+ + + + + + + +
+ + +
B E G L M N O R S T U  + + +

B

+
+
Book - Class in libsys
+
 
+
Book(int) - Constructor for class libsys.Book
+
+
Create new Book with given id (Usually used as placeholders)
+
+
Book(String, int, String) - Constructor for class libsys.Book
+
+
Create new Book with given title, id and status (Usually used for new Book creation)
+
+
Book(int, String, String, int[]) - Constructor for class libsys.Book
+
+
Create new Book with given id, title, status and dueDate (Usually used for initialization from database)
+
+
BookFactory - Class in libsys
+
 
+
BookFactory() - Constructor for class libsys.BookFactory
+
+
Create a new empty BookFactory
+
+
BookFactory(String) - Constructor for class libsys.BookFactory
+
+
Create a new BookFactory and fill it with information from a JSON file
+
+
bookStatus() - Method in class libsys.User
+
+
Get Book ids of the books
+
+
borrowNewBook(int) - Method in class libsys.User
+
+
User borrows a Book
+
+
+ + + +

E

+
+
EditBookDialog - Class in libsys
+
 
+
EditBookDialog(Frame, boolean, Book) - Constructor for class libsys.EditBookDialog
+
+
Create new EditBookDialog
+
+
EditUserDialog - Class in libsys
+
 
+
EditUserDialog(Frame, boolean, User, BookFactory) - Constructor for class libsys.EditUserDialog
+
+
Creates new EditUserDialog
+
+
+ + + +

G

+
+
get(String) - Method in class libsys.Settings
+
+
Get the value associated to the field name
+
+
getBook(int) - Method in class libsys.BookFactory
+
+
Looks for a Book with the given id
+
+
getBook(String) - Method in class libsys.BookFactory
+
+
Linear search through the array list for Book with the given Title
+
+
getBooksFilename() - Method in class libsys.SettingsDialog
+
+
Get the new Books file name
+
+
getDueDate() - Method in class libsys.Book
+
+
Returns the due date of the Book
+
+
getId() - Method in class libsys.Book
+
+
Returns the id of the Book
+
+
getId() - Method in class libsys.User
+
+
Gets id of this User
+
+
getKey(int) - Method in class libsys.Settings
+
+
Get the field name from that specific location in the array list
+
+
getLimit() - Method in class libsys.NewUserDialog
+
+
Get the limit of the new User
+
+
getLimit() - Method in class libsys.User
+
+
Gets limit of Book this User can borrow
+
+
getName() - Method in class libsys.NewUserDialog
+
+
Get the name of the new User
+
+
getName() - Method in class libsys.User
+
+
Gets name of this User
+
+
getNewLimit() - Method in class libsys.EditUserDialog
+
+
Returns the limit from the limitTxtField
+
+
getNewName() - Method in class libsys.EditBookDialog
+
+
Returns the name from the nameTxtField
+
+
getNewName() - Method in class libsys.EditUserDialog
+
+
Returns the name from the nameTxtField
+
+
getReturnStatus() - Method in class libsys.EditBookDialog
+
+
Returns if the user selected "Save" or "Cancel"
+
+
getReturnStatus() - Method in class libsys.EditUserDialog
+
+
Returns if the user selected "Save" or "Cancel"
+
+
getReturnStatus() - Method in class libsys.NewBookDialog
+
+
Get the return status
+
+
getReturnStatus() - Method in class libsys.NewUserDialog
+
+
Get the return status
+
+
getReturnStatus() - Method in class libsys.RentDialog
+
+
Get the return status
+
+
getReturnStatus() - Method in class libsys.ReturnDialog
+
+
Get the return status
+
+
getReturnStatus() - Method in class libsys.SettingsDialog
+
+
Get the return status
+
+
getStatus() - Method in class libsys.Book
+
+
Returns the status of the Book
+
+
getStatus() - Method in class libsys.NewBookDialog
+
+
Get the status of the new Book
+
+
getTitle() - Method in class libsys.Book
+
+
Returns the title of the Book
+
+
getTitle() - Method in class libsys.NewBookDialog
+
+
Get the name of the new Book
+
+
getTitle() - Method in class libsys.SettingsDialog
+
+
Get the new title for the MainGUi
+
+
getUser(String) - Method in class libsys.UserFactory
+
+
Looks for the User with the given name
+
+
getUser(int) - Method in class libsys.UserFactory
+
+
Looks for a User with the given id
+
+
getUsersFilename() - Method in class libsys.SettingsDialog
+
+
Get the new Users file name
+
+
+ + + +

L

+
+
libsys - package libsys
+
 
+
+ + + +

M

+
+
Main - Class in libsys
+
 
+
Main() - Constructor for class libsys.Main
+
 
+
main(String[]) - Static method in class libsys.Main
+
+
Start the applicationn
+
+
MainGUI - Class in libsys
+
 
+
MainGUI(Handler, Settings) - Constructor for class libsys.MainGUI
+
+
Creates a new MainGUI
+
+
+ + + +

N

+
+
newBook(String, String) - Method in class libsys.BookFactory
+
+
Adds a new Book into this class
+
+
NewBookDialog - Class in libsys
+
 
+
NewBookDialog(Frame, boolean) - Constructor for class libsys.NewBookDialog
+
+
Creates new form NewBookDialog
+
+
newUser(String, int) - Method in class libsys.UserFactory
+
+
Adds a new User into this class
+
+
NewUserDialog - Class in libsys
+
 
+
NewUserDialog(Frame, boolean) - Constructor for class libsys.NewUserDialog
+
+
Creates new form NewUserDialog
+
+
+ + + +

O

+
+
overdueFine(int[]) - Method in class libsys.Book
+
+
Calculate the overdue fine
+
+
+ + + +

R

+
+
rent(int[]) - Method in class libsys.Book
+
+
Call to rent book, return if renting is successful
+
+
RentDialog - Class in libsys
+
 
+
RentDialog(Frame, boolean, Handler) - Constructor for class libsys.RentDialog
+
+
Creates new form RentDialog
+
+
returnBook(int) - Method in class libsys.User
+
+
User returns a Book
+
+
ReturnDialog - Class in libsys
+
 
+
ReturnDialog(Frame, boolean, Handler, int) - Constructor for class libsys.ReturnDialog
+
+
Creates a new ReturnDialog
+
+
returned() - Method in class libsys.Book
+
+
Return the Book to the shelf
+
+
+ + + +

S

+
+
setBookFileName(String) - Method in class libsys.BookFactory
+
+
Update the output filename for the object
+
+
setBooksFilename(String) - Method in class libsys.Settings
+
+
Change the file name for the Books
+
+
setLimit(int) - Method in class libsys.User
+
+
Change limit of this User
+
+
setName(String) - Method in class libsys.User
+
+
Change name of this User
+
+
Settings - Class in libsys
+
 
+
Settings(String) - Constructor for class libsys.Settings
+
+
Creates new Settings importing information from the given file name
+
+
SettingsDialog - Class in libsys
+
 
+
SettingsDialog(Frame, boolean, Settings) - Constructor for class libsys.SettingsDialog
+
+
Creates new SettingsDialog
+
+
setTitle(String) - Method in class libsys.Book
+
+
Set the title to the given title
+
+
setTitle(String) - Method in class libsys.Settings
+
+
Change the title of the application
+
+
setUserFileName(String) - Method in class libsys.UserFactory
+
+
Update the output filename for the object
+
+
setUsersFilename(String) - Method in class libsys.Settings
+
+
Change the file name for the Users
+
+
size() - Method in class libsys.Settings
+
+
Amount of fields in the settings
+
+
status() - Method in class libsys.User
+
+
Check status of the User
+
+
+ + + +

T

+
+
toFile() - Method in class libsys.Settings
+
+
Save the settings to the given input file
+
+
toJsonFile() - Method in class libsys.BookFactory
+
+
Output the data into a JSON file replacing the input file (or if filename not given, "books.json")
+
+
toJsonFile() - Method in class libsys.UserFactory
+
+
Output the data into a JSON file replacing the input file (or if filename not given, "users.json")
+
+
+ + + +

U

+
+
update(Book, Book) - Method in class libsys.BookFactory
+
+
Replacing a Book in the array list with a new Book
+
+
update(User, User) - Method in class libsys.UserFactory
+
+
Replacing a User in the array list with a new User
+
+
User - Class in libsys
+
 
+
User(String, int, int) - Constructor for class libsys.User
+
+
Creates a new User with name, id and limit (usually used to add new User)
+
+
User(String, int, int, ArrayList<Integer>) - Constructor for class libsys.User
+
+
Creates a new User with name, id, limit and books (usually used to initialize from database)
+
+
UserFactory - Class in libsys
+
 
+
UserFactory() - Constructor for class libsys.UserFactory
+
+
Create a new empty UserFactory
+
+
UserFactory(String) - Constructor for class libsys.UserFactory
+
+
Create a new UserFactory and fill it with information from a JSON file
+
+
+B E G L M N O R S T U 
+ +
+ + + + + + + +
+ + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..853c8b3 --- /dev/null +++ b/docs/index.html @@ -0,0 +1,73 @@ + + + + + + +LibrarySystem 1.0 API + + + + + + +<noscript> +<div>JavaScript is disabled on your browser.</div> +</noscript> +<h2>Frame Alert</h2> +<p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="libsys/package-summary.html">Non-frame version</a>.</p> + + + diff --git a/docs/index.md b/docs/index.md deleted file mode 100644 index e47f3d3..0000000 --- a/docs/index.md +++ /dev/null @@ -1,95 +0,0 @@ -# Documentations - -## Table of Content - -- [Main](#main) -- [Book](#book) -- [Book Factory](#book-factory) -- [User](#user) -- [User Factory](#user-factory) - -# Main - -## Functions - -| Return | Method | Description | -|:-------|:-------|:------------| -| boolean | borrowBook(User user, Book book) | Return if the borrow of the book on both `BookFactory` and `UserFactory` is successful -| boolean | returnBook(User user, Book book) | Return if the return of the book on both `BookFactory` and `UserFactory` is successful -| int[] | calDueDate(int days) | Calculate the due date from the current date according to user's permission -| int[] | currentDay() | Returns the current date in an array form | - -# Book - -## Constructors - -| Method | Description | -|:-------|:------------| -| Book(int id) | Create a book with a specific id | -| Book(String title, int id) | Create a book with specific id and title | - -## Functions - -| Return | Method | Description | -|:-------|:-------|:------------| -| String | getTitle() | Returns the title of the book | -| String | getStatus() | Returns the status of the book | -| String | getId() | Returns the id of the book | -| void | setTitle() | Set the title of the book | -| boolean | rent(int[] dueDate) | Returns if the rent action is successful and set the due date to the given input | -| void | returned() | Return the book | -| double | overdueFine(int[] currentDay) | Calculate and return the amount of fine to be charged
(Fine rate is 0.25 per day; Max fine is 5) | - -# Book Factory - -## Constructors - -| Method | Description | -|:-------|:------------| -| BookFactory() | Creates an empty BookFactory | - -## Functions - -| Return | Method | Description | -|:-------|:-------|:------------| -| Book | newBook(String title) | Creates a new Book with the given title and returns it | -| Book | getBook(int index) | Returns the book of the given index if it exist, else throw null pointer exception | -| Book | getBook(String title) | Returns the book of the given title if it exist, else throw null pointer exception | -| void | update(Book newbook) | Replaces the existing book of the same id with this new one | - -# User - -## Constructors - -| Method | Description | -|:-------|:------------| -| User(String name, int id, int limit) | Create a new User with given name, id and limit | - -## Functions - -| Return | Method | Description | -|:-------|:-------|:------------| -| String | getName() | Returns the name of the user | -| int | getId() | Returns id of the user | -| void | setName() | Set the name of the user | -| boolean | status() | Check if the user reached the limit of amount of books the user can borrow | -| List | bookStatus() | Return a list consisting of book ids for all the books rented by the user | -| 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 | -| boolean | returnBook(int id) | Check if the book is borrowed by the user then remove it from the list | - -# User Factory - -## Constructors - -| Method | Description | -|:-------|:------------| -| UserFactory() | Creates a new empty factory | - -## Functions - -| Return | Method | Description | -|:-------|:-------|:------------| -| User | newUser(String name, int limit) | Creates a new user and returns the created user | -| User | getUser(String name) | Gets the user with the given name from the factory | -| User | getUser(int index) | Gets the user with the given id from the factory | -| void | update(User oldUser, User newUser) | Update by replacing the existing user with the new one | diff --git a/docs/libsys/Book.html b/docs/libsys/Book.html new file mode 100644 index 0000000..d9a7583 --- /dev/null +++ b/docs/libsys/Book.html @@ -0,0 +1,478 @@ + + + + + + +Book (LibrarySystem 1.0 API) + + + + + + + + + + + + +
+
libsys
+

Class Book

+
+
+ +
+
    +
  • +
    +
    +
    public class Book
    +extends Object
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + + + + + +
      Constructors 
      Constructor and Description
      Book(int id) +
      Create new Book with given id (Usually used as placeholders)
      +
      Book(int id, + String title, + String status, + int[] dueDate) +
      Create new Book with given id, title, status and dueDate (Usually used for initialization from database)
      +
      Book(String title, + int id, + String status) +
      Create new Book with given title, id and status (Usually used for new Book creation)
      +
      +
    • +
    + + +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        Book

        +
        public Book(int id)
        +
        Create new Book with given id (Usually used as placeholders)
        +
        +
        Parameters:
        +
        id - Identification number of the Book
        +
        +
      • +
      + + + +
        +
      • +

        Book

        +
        public Book(String title,
        +            int id,
        +            String status)
        +
        Create new Book with given title, id and status (Usually used for new Book creation)
        +
        +
        Parameters:
        +
        title - Title of the Book
        +
        id - Identification number of the Book
        +
        status - Status of the Book
        +
        +
      • +
      + + + +
        +
      • +

        Book

        +
        public Book(int id,
        +            String title,
        +            String status,
        +            int[] dueDate)
        +
        Create new Book with given id, title, status and dueDate (Usually used for initialization from database)
        +
        +
        Parameters:
        +
        id - Identification number of the Book
        +
        title - Title of the Book
        +
        status - Status of the Book
        +
        dueDate - Due date of the Book
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getTitle

        +
        public String getTitle()
        +
        Returns the title of the Book
        +
        +
        Returns:
        +
        title
        +
        +
      • +
      + + + +
        +
      • +

        getStatus

        +
        public String getStatus()
        +
        Returns the status of the Book
        +
        +
        Returns:
        +
        status (AVAILABLE || RENTED || RESERVED || NOT AVAILABLE)
        +
        +
      • +
      + + + +
        +
      • +

        getId

        +
        public int getId()
        +
        Returns the id of the Book
        +
        +
        Returns:
        +
        id
        +
        +
      • +
      + + + +
        +
      • +

        getDueDate

        +
        public int[] getDueDate()
        +
        Returns the due date of the Book
        +
        +
        Returns:
        +
        due date ([yyyy][mm][dd])
        +
        +
      • +
      + + + +
        +
      • +

        setTitle

        +
        public void setTitle(String title)
        +
        Set the title to the given title
        +
        +
        Parameters:
        +
        title - The new title of the Book
        +
        +
      • +
      + + + +
        +
      • +

        rent

        +
        public boolean rent(int[] dueDate)
        +
        Call to rent book, return if renting is successful
        +
        +
        Parameters:
        +
        dueDate - The new due date of the Book
        +
        Returns:
        +
        if renting is successful
        +
        +
      • +
      + + + +
        +
      • +

        returned

        +
        public void returned()
        +
        Return the Book to the shelf
        +
      • +
      + + + +
        +
      • +

        overdueFine

        +
        public double overdueFine(int[] currentDay)
        +
        Calculate the overdue fine
        +
        +
        Parameters:
        +
        currentDay - Today's date
        +
        Returns:
        +
        Price of the fine
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/BookFactory.html b/docs/libsys/BookFactory.html new file mode 100644 index 0000000..fbc6fa1 --- /dev/null +++ b/docs/libsys/BookFactory.html @@ -0,0 +1,408 @@ + + + + + + +BookFactory (LibrarySystem 1.0 API) + + + + + + + + + + + + +
+
libsys
+

Class BookFactory

+
+
+ +
+
    +
  • +
    +
    +
    public class BookFactory
    +extends Object
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        BookFactory

        +
        public BookFactory()
        +
        Create a new empty BookFactory
        +
      • +
      + + + +
        +
      • +

        BookFactory

        +
        public BookFactory(String bookFilename)
        +
        Create a new BookFactory and fill it with information from a JSON file
        +
        +
        Parameters:
        +
        bookFilename - Name of the input JSON file
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        toJsonFile

        +
        public void toJsonFile()
        +
        Output the data into a JSON file replacing the input file (or if filename not given, "books.json")
        +
      • +
      + + + +
        +
      • +

        setBookFileName

        +
        public void setBookFileName(String bookFilename)
        +
        Update the output filename for the object
        +
        +
        Parameters:
        +
        bookFilename - The new filename
        +
        +
      • +
      + + + +
        +
      • +

        newBook

        +
        public Book newBook(String title,
        +                    String status)
        +
        Adds a new Book into this class
        +
        +
        Parameters:
        +
        title - Title of the Book
        +
        status - Status of the Book
        +
        Returns:
        +
        The new Book that is just created
        +
        +
      • +
      + + + +
        +
      • +

        getBook

        +
        public Book getBook(int index)
        +
        Looks for a Book with the given id
        +
        +
        Parameters:
        +
        index - id of the Book to be found
        +
        Returns:
        +
        Book with the given id
        +
        +
      • +
      + + + +
        +
      • +

        getBook

        +
        public Book getBook(String title)
        +
        Linear search through the array list for Book with the given Title
        +
        +
        Parameters:
        +
        title - Title of the Book to be found
        +
        Returns:
        +
        Book with the given title
        +
        +
      • +
      + + + +
        +
      • +

        update

        +
        public void update(Book oldBook,
        +                   Book newBook)
        +
        Replacing a Book in the array list with a new Book
        +
        +
        Parameters:
        +
        oldBook - Book to be replaced
        +
        newBook - Book replacing it
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/EditBookDialog.html b/docs/libsys/EditBookDialog.html new file mode 100644 index 0000000..d368040 --- /dev/null +++ b/docs/libsys/EditBookDialog.html @@ -0,0 +1,465 @@ + + + + + + +EditBookDialog (LibrarySystem 1.0 API) + + + + + + + + + + + + +
+
libsys
+

Class EditBookDialog

+
+
+ +
+ +
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        EditBookDialog

        +
        public EditBookDialog(Frame parent,
        +                      boolean modal,
        +                      Book book)
        +
        Create new EditBookDialog
        +
        +
        Parameters:
        +
        parent - java.awt.Frame
        +
        modal - boolean
        +
        book - Book
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getNewName

        +
        public String getNewName()
        +
        Returns the name from the nameTxtField
        +
        +
        Returns:
        +
        new Book name
        +
        +
      • +
      + + + +
        +
      • +

        getReturnStatus

        +
        public boolean getReturnStatus()
        +
        Returns if the user selected "Save" or "Cancel"
        +
        +
        Returns:
        +
        T:"Save"|F:"Cancel"
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/EditUserDialog.html b/docs/libsys/EditUserDialog.html new file mode 100644 index 0000000..c884e03 --- /dev/null +++ b/docs/libsys/EditUserDialog.html @@ -0,0 +1,488 @@ + + + + + + +EditUserDialog (LibrarySystem 1.0 API) + + + + + + + + + + + + +
+
libsys
+

Class EditUserDialog

+
+
+ +
+ +
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        EditUserDialog

        +
        public EditUserDialog(Frame parent,
        +                      boolean modal,
        +                      User user,
        +                      BookFactory books)
        +
        Creates new EditUserDialog
        +
        +
        Parameters:
        +
        parent - java.awt.Frame
        +
        modal - boolean
        +
        user - User
        +
        books - BookFactory
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getReturnStatus

        +
        public boolean getReturnStatus()
        +
        Returns if the user selected "Save" or "Cancel"
        +
        +
        Returns:
        +
        T:"Save"|F:"Cancel"
        +
        +
      • +
      + + + +
        +
      • +

        getNewName

        +
        public String getNewName()
        +
        Returns the name from the nameTxtField
        +
        +
        Returns:
        +
        new User name
        +
        +
      • +
      + + + +
        +
      • +

        getNewLimit

        +
        public int getNewLimit()
        +
        Returns the limit from the limitTxtField
        +
        +
        Returns:
        +
        new User limit
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/Main.html b/docs/libsys/Main.html new file mode 100644 index 0000000..60ac2f6 --- /dev/null +++ b/docs/libsys/Main.html @@ -0,0 +1,278 @@ + + + + + + +Main (LibrarySystem 1.0 API) + + + + + + + + + + + + +
+
libsys
+

Class Main

+
+
+ +
+
    +
  • +
    +
    +
    public class Main
    +extends Object
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        Main

        +
        public Main()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        main

        +
        public static void main(String[] args)
        +
        Start the applicationn
        +
        +
        Parameters:
        +
        args -
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/MainGUI.html b/docs/libsys/MainGUI.html new file mode 100644 index 0000000..9338543 --- /dev/null +++ b/docs/libsys/MainGUI.html @@ -0,0 +1,408 @@ + + + + + + +MainGUI (LibrarySystem 1.0 API) + + + + + + + + + + + + +
+
libsys
+

Class MainGUI

+
+
+ +
+ +
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        MainGUI

        +
        public MainGUI(libsys.Handler handler,
        +               Settings settings)
        +
        Creates a new MainGUI
        +
        +
        Parameters:
        +
        handler - Given Handler from Main
        +
        settings - Given Settings from Main
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/NewBookDialog.html b/docs/libsys/NewBookDialog.html new file mode 100644 index 0000000..884e56d --- /dev/null +++ b/docs/libsys/NewBookDialog.html @@ -0,0 +1,484 @@ + + + + + + +NewBookDialog (LibrarySystem 1.0 API) + + + + + + + + + + + + +
+
libsys
+

Class NewBookDialog

+
+
+ +
+ +
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        NewBookDialog

        +
        public NewBookDialog(Frame parent,
        +                     boolean modal)
        +
        Creates new form NewBookDialog
        +
        +
        Parameters:
        +
        parent - java.awt.Frame
        +
        modal - boolean
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getReturnStatus

        +
        public int getReturnStatus()
        +
        Get the return status
        +
        +
        Returns:
        +
        -1:Cancel|1:Create
        +
        +
      • +
      + + + +
        +
      • +

        getTitle

        +
        public String getTitle()
        +
        Get the name of the new Book
        +
        +
        Overrides:
        +
        getTitle in class Dialog
        +
        Returns:
        +
        name from titleTxtField
        +
        +
      • +
      + + + +
        +
      • +

        getStatus

        +
        public String getStatus()
        +
        Get the status of the new Book
        +
        +
        Returns:
        +
        status from statusComboBox
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/NewUserDialog.html b/docs/libsys/NewUserDialog.html new file mode 100644 index 0000000..2bad2ee --- /dev/null +++ b/docs/libsys/NewUserDialog.html @@ -0,0 +1,484 @@ + + + + + + +NewUserDialog (LibrarySystem 1.0 API) + + + + + + + + + + + + +
+
libsys
+

Class NewUserDialog

+
+
+ +
+ +
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        NewUserDialog

        +
        public NewUserDialog(Frame parent,
        +                     boolean modal)
        +
        Creates new form NewUserDialog
        +
        +
        Parameters:
        +
        parent - java.awt.Frame
        +
        modal - boolean
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getReturnStatus

        +
        public int getReturnStatus()
        +
        Get the return status
        +
        +
        Returns:
        +
        -1:Cancel|1:Create
        +
        +
      • +
      + + + +
        +
      • +

        getName

        +
        public String getName()
        +
        Get the name of the new User
        +
        +
        Overrides:
        +
        getName in class Component
        +
        Returns:
        +
        name from nameTxtField
        +
        +
      • +
      + + + +
        +
      • +

        getLimit

        +
        public int getLimit()
        +
        Get the limit of the new User
        +
        +
        Returns:
        +
        limit from limitTxtField
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/RentDialog.html b/docs/libsys/RentDialog.html new file mode 100644 index 0000000..a03e8e6 --- /dev/null +++ b/docs/libsys/RentDialog.html @@ -0,0 +1,445 @@ + + + + + + +RentDialog (LibrarySystem 1.0 API) + + + + + + + + + + + + +
+
libsys
+

Class RentDialog

+
+
+ +
+ +
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        RentDialog

        +
        public RentDialog(Frame parent,
        +                  boolean modal,
        +                  libsys.Handler handler)
        +
        Creates new form RentDialog
        +
        +
        Parameters:
        +
        parent - java.awt.Frame
        +
        modal - boolean
        +
        handler - Handler
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getReturnStatus

        +
        public int getReturnStatus()
        +
        Get the return status
        +
        +
        Returns:
        +
        -1:Cancel|others:Book id
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/ReturnDialog.html b/docs/libsys/ReturnDialog.html new file mode 100644 index 0000000..1b34e2c --- /dev/null +++ b/docs/libsys/ReturnDialog.html @@ -0,0 +1,448 @@ + + + + + + +ReturnDialog (LibrarySystem 1.0 API) + + + + + + + + + + + + +
+
libsys
+

Class ReturnDialog

+
+
+ +
+ +
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        ReturnDialog

        +
        public ReturnDialog(Frame parent,
        +                    boolean modal,
        +                    libsys.Handler handler,
        +                    int id)
        +
        Creates a new ReturnDialog
        +
        +
        Parameters:
        +
        parent - java.awt.Frame
        +
        modal - boolean
        +
        handler - Handler
        +
        id - int - Returning Book's User id
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getReturnStatus

        +
        public int getReturnStatus()
        +
        Get the return status
        +
        +
        Returns:
        +
        -1:Cancel|others:Book id
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/Settings.html b/docs/libsys/Settings.html new file mode 100644 index 0000000..6f95eb5 --- /dev/null +++ b/docs/libsys/Settings.html @@ -0,0 +1,405 @@ + + + + + + +Settings (LibrarySystem 1.0 API) + + + + + + + + + + + + +
+
libsys
+

Class Settings

+
+
+ +
+
    +
  • +
    +
    +
    public class Settings
    +extends Object
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        Settings

        +
        public Settings(String settingsFileName)
        +
        Creates new Settings importing information from the given file name
        +
        +
        Parameters:
        +
        settingsFileName - File name of existing settings stored
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        toFile

        +
        public void toFile()
        +
        Save the settings to the given input file
        +
      • +
      + + + +
        +
      • +

        size

        +
        public int size()
        +
        Amount of fields in the settings
        +
        +
        Returns:
        +
        Amount of keys
        +
        +
      • +
      + + + +
        +
      • +

        getKey

        +
        public String getKey(int location)
        +
        Get the field name from that specific location in the array list
        +
        +
        Parameters:
        +
        location - Location of the field in the array list
        +
        Returns:
        +
        The field name
        +
        +
      • +
      + + + +
        +
      • +

        get

        +
        public String get(String key)
        +
        Get the value associated to the field name
        +
        +
        Parameters:
        +
        key - Field name
        +
        Returns:
        +
        Field value
        +
        +
      • +
      + + + +
        +
      • +

        setTitle

        +
        public void setTitle(String newTitle)
        +
        Change the title of the application
        +
        +
        Parameters:
        +
        newTitle - New Title
        +
        +
      • +
      + + + +
        +
      • +

        setUsersFilename

        +
        public void setUsersFilename(String newUsersFilename)
        +
        Change the file name for the Users
        +
        +
        Parameters:
        +
        newUsersFilename - New file name for Users
        +
        +
      • +
      + + + +
        +
      • +

        setBooksFilename

        +
        public void setBooksFilename(String newBooksFilename)
        +
        Change the file name for the Books
        +
        +
        Parameters:
        +
        newBooksFilename - New file name for Books
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/SettingsDialog.html b/docs/libsys/SettingsDialog.html new file mode 100644 index 0000000..f565dea --- /dev/null +++ b/docs/libsys/SettingsDialog.html @@ -0,0 +1,507 @@ + + + + + + +SettingsDialog (LibrarySystem 1.0 API) + + + + + + + + + + + + +
+
libsys
+

Class SettingsDialog

+
+
+ +
+ +
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        SettingsDialog

        +
        public SettingsDialog(Frame parent,
        +                      boolean modal,
        +                      Settings preset)
        +
        Creates new SettingsDialog
        +
        +
        Parameters:
        +
        parent - java.awt.Frame
        +
        modal - boolean
        +
        preset - Settings
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getTitle

        +
        public String getTitle()
        +
        Get the new title for the MainGUi
        +
        +
        Overrides:
        +
        getTitle in class Dialog
        +
        Returns:
        +
        Get title from titleTxtField
        +
        +
      • +
      + + + +
        +
      • +

        getUsersFilename

        +
        public String getUsersFilename()
        +
        Get the new Users file name
        +
        +
        Returns:
        +
        Users file name from usersFilenameTxt
        +
        +
      • +
      + + + +
        +
      • +

        getBooksFilename

        +
        public String getBooksFilename()
        +
        Get the new Books file name
        +
        +
        Returns:
        +
        Books file name from booksFilenameTxt
        +
        +
      • +
      + + + +
        +
      • +

        getReturnStatus

        +
        public int getReturnStatus()
        +
        Get the return status
        +
        +
        Returns:
        +
        -1:Discard|1:Save
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/User.html b/docs/libsys/User.html new file mode 100644 index 0000000..720e2e1 --- /dev/null +++ b/docs/libsys/User.html @@ -0,0 +1,483 @@ + + + + + + +User (LibrarySystem 1.0 API) + + + + + + + + + + + + +
+
libsys
+

Class User

+
+
+ +
+
    +
  • +
    +
    +
    public class User
    +extends Object
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        User

        +
        public User(String name,
        +            int id,
        +            int limit)
        +
        Creates a new User with name, id and limit (usually used to add new User)
        +
        +
        Parameters:
        +
        name - Name of this User
        +
        id - id of this User
        +
        limit - Limit of Book this User can borrow
        +
        +
      • +
      + + + +
        +
      • +

        User

        +
        public User(String name,
        +            int id,
        +            int limit,
        +            ArrayList<Integer> books)
        +
        Creates a new User with name, id, limit and books (usually used to initialize from database)
        +
        +
        Parameters:
        +
        name - Name of this User
        +
        id - id of this User
        +
        limit - Limit of Book this User can borrow
        +
        books - ArrayList of Book ids borrowed by the User
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getName

        +
        public String getName()
        +
        Gets name of this User
        +
        +
        Returns:
        +
        Name
        +
        +
      • +
      + + + +
        +
      • +

        getId

        +
        public int getId()
        +
        Gets id of this User
        +
        +
        Returns:
        +
        id
        +
        +
      • +
      + + + +
        +
      • +

        getLimit

        +
        public int getLimit()
        +
        Gets limit of Book this User can borrow
        +
        +
        Returns:
        +
        Book borrowing limit
        +
        +
      • +
      + + + +
        +
      • +

        setName

        +
        public void setName(String name)
        +
        Change name of this User
        +
        +
        Parameters:
        +
        name - New name of the User
        +
        +
      • +
      + + + +
        +
      • +

        setLimit

        +
        public void setLimit(int limit)
        +
        Change limit of this User
        +
        +
        Parameters:
        +
        limit - New limit of the User
        +
        +
      • +
      + + + +
        +
      • +

        status

        +
        public boolean status()
        +
        Check status of the User
        +
        +
        Returns:
        +
        If the User is already at the borrowing limit
        +
        +
      • +
      + + + +
        +
      • +

        bookStatus

        +
        public int[] bookStatus()
        +
        Get Book ids of the books
        +
        +
        Returns:
        +
        Array of Book ids borrowed by this User
        +
        +
      • +
      + + + +
        +
      • +

        borrowNewBook

        +
        public boolean borrowNewBook(int id)
        +
        User borrows a Book
        +
        +
        Parameters:
        +
        id - id of the Book to tbe borrowed
        +
        Returns:
        +
        If the borrowing operation is successful
        +
        +
      • +
      + + + +
        +
      • +

        returnBook

        +
        public boolean returnBook(int id)
        +
        User returns a Book
        +
        +
        Parameters:
        +
        id - id of the Book to be returned
        +
        Returns:
        +
        If the returning operation is successful
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/UserFactory.html b/docs/libsys/UserFactory.html new file mode 100644 index 0000000..26c1407 --- /dev/null +++ b/docs/libsys/UserFactory.html @@ -0,0 +1,408 @@ + + + + + + +UserFactory (LibrarySystem 1.0 API) + + + + + + + + + + + + +
+
libsys
+

Class UserFactory

+
+
+ +
+
    +
  • +
    +
    +
    public class UserFactory
    +extends Object
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        UserFactory

        +
        public UserFactory()
        +
        Create a new empty UserFactory
        +
      • +
      + + + +
        +
      • +

        UserFactory

        +
        public UserFactory(String userFilename)
        +
        Create a new UserFactory and fill it with information from a JSON file
        +
        +
        Parameters:
        +
        userFilename - Name of the input JSON file
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        toJsonFile

        +
        public void toJsonFile()
        +
        Output the data into a JSON file replacing the input file (or if filename not given, "users.json")
        +
      • +
      + + + +
        +
      • +

        setUserFileName

        +
        public void setUserFileName(String userFilename)
        +
        Update the output filename for the object
        +
        +
        Parameters:
        +
        userFilename - The new filename
        +
        +
      • +
      + + + +
        +
      • +

        newUser

        +
        public User newUser(String name,
        +                    int limit)
        +
        Adds a new User into this class
        +
        +
        Parameters:
        +
        name - Name of the User
        +
        limit - Limit of Book the User can borrow
        +
        Returns:
        +
        The new User that is just created
        +
        +
      • +
      + + + +
        +
      • +

        getUser

        +
        public User getUser(String name)
        +
        Looks for the User with the given name
        +
        +
        Parameters:
        +
        name - Name of the User to be found
        +
        Returns:
        +
        User with the given name
        +
        +
      • +
      + + + +
        +
      • +

        getUser

        +
        public User getUser(int index)
        +
        Looks for a User with the given id
        +
        +
        Parameters:
        +
        index - id of the User to be found
        +
        Returns:
        +
        User with the given id
        +
        +
      • +
      + + + +
        +
      • +

        update

        +
        public void update(User oldUser,
        +                   User newUser)
        +
        Replacing a User in the array list with a new User
        +
        +
        Parameters:
        +
        oldUser - User to be replaced
        +
        newUser - User replacing it
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/class-use/Book.html b/docs/libsys/class-use/Book.html new file mode 100644 index 0000000..d8f07df --- /dev/null +++ b/docs/libsys/class-use/Book.html @@ -0,0 +1,195 @@ + + + + + + +Uses of Class libsys.Book (LibrarySystem 1.0 API) + + + + + + + + + + + +
+

Uses of Class
libsys.Book

+
+
+
    +
  • +
      +
    • + + +

      Uses of Book in libsys

      + + + + + + + + + + + + + + + + + + + + +
      Methods in libsys that return Book 
      Modifier and TypeMethod and Description
      BookBookFactory.getBook(int index) +
      Looks for a Book with the given id
      +
      BookBookFactory.getBook(String title) +
      Linear search through the array list for Book with the given Title
      +
      BookBookFactory.newBook(String title, + String status) +
      Adds a new Book into this class
      +
      + + + + + + + + + + + + +
      Methods in libsys with parameters of type Book 
      Modifier and TypeMethod and Description
      voidBookFactory.update(Book oldBook, + Book newBook) +
      Replacing a Book in the array list with a new Book
      +
      + + + + + + + + + + +
      Constructors in libsys with parameters of type Book 
      Constructor and Description
      EditBookDialog(Frame parent, + boolean modal, + Book book) +
      Create new EditBookDialog
      +
      +
    • +
    +
  • +
+
+ + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/class-use/BookFactory.html b/docs/libsys/class-use/BookFactory.html new file mode 100644 index 0000000..c1a25e4 --- /dev/null +++ b/docs/libsys/class-use/BookFactory.html @@ -0,0 +1,152 @@ + + + + + + +Uses of Class libsys.BookFactory (LibrarySystem 1.0 API) + + + + + + + + + + + +
+

Uses of Class
libsys.BookFactory

+
+
+ +
+ + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/class-use/EditBookDialog.html b/docs/libsys/class-use/EditBookDialog.html new file mode 100644 index 0000000..f68e280 --- /dev/null +++ b/docs/libsys/class-use/EditBookDialog.html @@ -0,0 +1,124 @@ + + + + + + +Uses of Class libsys.EditBookDialog (LibrarySystem 1.0 API) + + + + + + + + + + + +
+

Uses of Class
libsys.EditBookDialog

+
+
No usage of libsys.EditBookDialog
+ + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/class-use/EditUserDialog.html b/docs/libsys/class-use/EditUserDialog.html new file mode 100644 index 0000000..0f00a9b --- /dev/null +++ b/docs/libsys/class-use/EditUserDialog.html @@ -0,0 +1,124 @@ + + + + + + +Uses of Class libsys.EditUserDialog (LibrarySystem 1.0 API) + + + + + + + + + + + +
+

Uses of Class
libsys.EditUserDialog

+
+
No usage of libsys.EditUserDialog
+ + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/class-use/Main.html b/docs/libsys/class-use/Main.html new file mode 100644 index 0000000..ca7aef1 --- /dev/null +++ b/docs/libsys/class-use/Main.html @@ -0,0 +1,124 @@ + + + + + + +Uses of Class libsys.Main (LibrarySystem 1.0 API) + + + + + + + + + + + +
+

Uses of Class
libsys.Main

+
+
No usage of libsys.Main
+ + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/class-use/MainGUI.html b/docs/libsys/class-use/MainGUI.html new file mode 100644 index 0000000..838cd13 --- /dev/null +++ b/docs/libsys/class-use/MainGUI.html @@ -0,0 +1,124 @@ + + + + + + +Uses of Class libsys.MainGUI (LibrarySystem 1.0 API) + + + + + + + + + + + +
+

Uses of Class
libsys.MainGUI

+
+
No usage of libsys.MainGUI
+ + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/class-use/NewBookDialog.html b/docs/libsys/class-use/NewBookDialog.html new file mode 100644 index 0000000..784cb94 --- /dev/null +++ b/docs/libsys/class-use/NewBookDialog.html @@ -0,0 +1,124 @@ + + + + + + +Uses of Class libsys.NewBookDialog (LibrarySystem 1.0 API) + + + + + + + + + + + +
+

Uses of Class
libsys.NewBookDialog

+
+
No usage of libsys.NewBookDialog
+ + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/class-use/NewUserDialog.html b/docs/libsys/class-use/NewUserDialog.html new file mode 100644 index 0000000..095a0cc --- /dev/null +++ b/docs/libsys/class-use/NewUserDialog.html @@ -0,0 +1,124 @@ + + + + + + +Uses of Class libsys.NewUserDialog (LibrarySystem 1.0 API) + + + + + + + + + + + +
+

Uses of Class
libsys.NewUserDialog

+
+
No usage of libsys.NewUserDialog
+ + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/class-use/RentDialog.html b/docs/libsys/class-use/RentDialog.html new file mode 100644 index 0000000..dee7746 --- /dev/null +++ b/docs/libsys/class-use/RentDialog.html @@ -0,0 +1,124 @@ + + + + + + +Uses of Class libsys.RentDialog (LibrarySystem 1.0 API) + + + + + + + + + + + +
+

Uses of Class
libsys.RentDialog

+
+
No usage of libsys.RentDialog
+ + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/class-use/ReturnDialog.html b/docs/libsys/class-use/ReturnDialog.html new file mode 100644 index 0000000..ec7bdad --- /dev/null +++ b/docs/libsys/class-use/ReturnDialog.html @@ -0,0 +1,124 @@ + + + + + + +Uses of Class libsys.ReturnDialog (LibrarySystem 1.0 API) + + + + + + + + + + + +
+

Uses of Class
libsys.ReturnDialog

+
+
No usage of libsys.ReturnDialog
+ + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/class-use/Settings.html b/docs/libsys/class-use/Settings.html new file mode 100644 index 0000000..817bcff --- /dev/null +++ b/docs/libsys/class-use/Settings.html @@ -0,0 +1,157 @@ + + + + + + +Uses of Class libsys.Settings (LibrarySystem 1.0 API) + + + + + + + + + + + +
+

Uses of Class
libsys.Settings

+
+
+ +
+ + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/class-use/SettingsDialog.html b/docs/libsys/class-use/SettingsDialog.html new file mode 100644 index 0000000..bc8f13d --- /dev/null +++ b/docs/libsys/class-use/SettingsDialog.html @@ -0,0 +1,124 @@ + + + + + + +Uses of Class libsys.SettingsDialog (LibrarySystem 1.0 API) + + + + + + + + + + + +
+

Uses of Class
libsys.SettingsDialog

+
+
No usage of libsys.SettingsDialog
+ + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/class-use/User.html b/docs/libsys/class-use/User.html new file mode 100644 index 0000000..6fab085 --- /dev/null +++ b/docs/libsys/class-use/User.html @@ -0,0 +1,196 @@ + + + + + + +Uses of Class libsys.User (LibrarySystem 1.0 API) + + + + + + + + + + + +
+

Uses of Class
libsys.User

+
+
+
    +
  • +
      +
    • + + +

      Uses of User in libsys

      + + + + + + + + + + + + + + + + + + + + +
      Methods in libsys that return User 
      Modifier and TypeMethod and Description
      UserUserFactory.getUser(int index) +
      Looks for a User with the given id
      +
      UserUserFactory.getUser(String name) +
      Looks for the User with the given name
      +
      UserUserFactory.newUser(String name, + int limit) +
      Adds a new User into this class
      +
      + + + + + + + + + + + + +
      Methods in libsys with parameters of type User 
      Modifier and TypeMethod and Description
      voidUserFactory.update(User oldUser, + User newUser) +
      Replacing a User in the array list with a new User
      +
      + + + + + + + + + + +
      Constructors in libsys with parameters of type User 
      Constructor and Description
      EditUserDialog(Frame parent, + boolean modal, + User user, + BookFactory books) +
      Creates new EditUserDialog
      +
      +
    • +
    +
  • +
+
+ + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/class-use/UserFactory.html b/docs/libsys/class-use/UserFactory.html new file mode 100644 index 0000000..22a830c --- /dev/null +++ b/docs/libsys/class-use/UserFactory.html @@ -0,0 +1,124 @@ + + + + + + +Uses of Class libsys.UserFactory (LibrarySystem 1.0 API) + + + + + + + + + + + +
+

Uses of Class
libsys.UserFactory

+
+
No usage of libsys.UserFactory
+ + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/package-frame.html b/docs/libsys/package-frame.html new file mode 100644 index 0000000..b972ffb --- /dev/null +++ b/docs/libsys/package-frame.html @@ -0,0 +1,34 @@ + + + + + + +libsys (LibrarySystem 1.0 API) + + + + + +

libsys

+ + + diff --git a/docs/libsys/package-summary.html b/docs/libsys/package-summary.html new file mode 100644 index 0000000..66fcfb0 --- /dev/null +++ b/docs/libsys/package-summary.html @@ -0,0 +1,194 @@ + + + + + + +libsys (LibrarySystem 1.0 API) + + + + + + + + + + + +
+

Package libsys

+
+
+ +
+ + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/package-tree.html b/docs/libsys/package-tree.html new file mode 100644 index 0000000..e37cd35 --- /dev/null +++ b/docs/libsys/package-tree.html @@ -0,0 +1,174 @@ + + + + + + +libsys Class Hierarchy (LibrarySystem 1.0 API) + + + + + + + + + + + +
+

Hierarchy For Package libsys

+
+
+

Class Hierarchy

+ +
+ + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/libsys/package-use.html b/docs/libsys/package-use.html new file mode 100644 index 0000000..a3aa5ec --- /dev/null +++ b/docs/libsys/package-use.html @@ -0,0 +1,151 @@ + + + + + + +Uses of Package libsys (LibrarySystem 1.0 API) + + + + + + + + + + + +
+

Uses of Package
libsys

+
+
+ +
+ + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/overview-tree.html b/docs/overview-tree.html new file mode 100644 index 0000000..3de5fa7 --- /dev/null +++ b/docs/overview-tree.html @@ -0,0 +1,178 @@ + + + + + + +Class Hierarchy (LibrarySystem 1.0 API) + + + + + + + + + + + +
+

Hierarchy For All Packages

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +
+ + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/package-list b/docs/package-list new file mode 100644 index 0000000..7b0a194 --- /dev/null +++ b/docs/package-list @@ -0,0 +1 @@ +libsys diff --git a/docs/script.js b/docs/script.js new file mode 100644 index 0000000..b346356 --- /dev/null +++ b/docs/script.js @@ -0,0 +1,30 @@ +function show(type) +{ + count = 0; + for (var key in methods) { + var row = document.getElementById(key); + if ((methods[key] & type) != 0) { + row.style.display = ''; + row.className = (count++ % 2) ? rowColor : altColor; + } + else + row.style.display = 'none'; + } + updateTabs(type); +} + +function updateTabs(type) +{ + for (var value in tabs) { + var sNode = document.getElementById(tabs[value][0]); + var spanNode = sNode.firstChild; + if (value == type) { + sNode.className = activeTableTab; + spanNode.innerHTML = tabs[value][1]; + } + else { + sNode.className = tableTab; + spanNode.innerHTML = "" + tabs[value][1] + ""; + } + } +} diff --git a/docs/serialized-form.html b/docs/serialized-form.html new file mode 100644 index 0000000..e7912f3 --- /dev/null +++ b/docs/serialized-form.html @@ -0,0 +1,664 @@ + + + + + + +Serialized Form (LibrarySystem 1.0 API) + + + + + + + + + + + +
+

Serialized Form

+
+
+
    +
  • +

    Package libsys

    +
      +
    • + + +

      Class libsys.EditBookDialog extends JDialog implements Serializable

      +
        +
      • +

        Serialized Fields

        +
          +
        • +

          cancelBtn

          +
          JButton cancelBtn
          +
        • +
        • +

          dueDateLbl

          +
          JLabel dueDateLbl
          +
        • +
        • +

          idLbl

          +
          JLabel idLbl
          +
        • +
        • +

          nameLbl

          +
          JLabel nameLbl
          +
        • +
        • +

          nameTxtField

          +
          JTextField nameTxtField
          +
        • +
        • +

          saveBtn

          +
          JButton saveBtn
          +
        • +
        • +

          statusLbl

          +
          JLabel statusLbl
          +
        • +
        • +

          titleLbl

          +
          JLabel titleLbl
          +
        • +
        • +

          book

          +
          Book book
          +
        • +
        • +

          newName

          +
          String newName
          +
        • +
        • +

          returnStatus

          +
          boolean returnStatus
          +
        • +
        +
      • +
      +
    • +
    • + + +

      Class libsys.EditUserDialog extends JDialog implements Serializable

      +
        +
      • +

        Serialized Fields

        +
          +
        • +

          booksLbl

          +
          JLabel booksLbl
          +
        • +
        • +

          cancelBtn

          +
          JButton cancelBtn
          +
        • +
        • +

          errorLbl

          +
          JLabel errorLbl
          +
        • +
        • +

          idLbl

          +
          JLabel idLbl
          +
        • +
        • +

          limitLbl

          +
          JLabel limitLbl
          +
        • +
        • +

          limitTxtField

          +
          JTextField limitTxtField
          +
        • +
        • +

          nameLbl

          +
          JLabel nameLbl
          +
        • +
        • +

          nameTxtField

          +
          JTextField nameTxtField
          +
        • +
        • +

          saveBtn

          +
          JButton saveBtn
          +
        • +
        • +

          titleLbl

          +
          JLabel titleLbl
          +
        • +
        • +

          user

          +
          User user
          +
        • +
        • +

          books

          +
          BookFactory books
          +
        • +
        • +

          returnStatus

          +
          boolean returnStatus
          +
        • +
        • +

          newName

          +
          String newName
          +
        • +
        • +

          newLimit

          +
          int newLimit
          +
        • +
        +
      • +
      +
    • +
    • + + +

      Class libsys.MainGUI extends JFrame implements Serializable

      +
        +
      • +

        Serialized Fields

        +
          +
        • +

          handler

          +
          libsys.Handler handler
          +
        • +
        • +

          settings

          +
          Settings settings
          +
        • +
        • +

          book

          +
          Book book
          +
        • +
        • +

          user

          +
          User user
          +
        • +
        • +

          bookExist

          +
          boolean bookExist
          +
        • +
        • +

          userExist

          +
          boolean userExist
          +
        • +
        • +

          bookDueDate

          +
          JLabel bookDueDate
          +
        • +
        • +

          bookID

          +
          JLabel bookID
          +
        • +
        • +

          bookMgtLabel

          +
          JLabel bookMgtLabel
          +
        • +
        • +

          bookPanel

          +
          JPanel bookPanel
          +
        • +
        • +

          bookSearch

          +
          JTextField bookSearch
          +
        • +
        • +

          bookSearchBtn

          +
          JButton bookSearchBtn
          +
        • +
        • +

          bookStatus

          +
          JLabel bookStatus
          +
        • +
        • +

          bookTitle

          +
          JLabel bookTitle
          +
        • +
        • +

          createBookBtn

          +
          JButton createBookBtn
          +
        • +
        • +

          createUserBtn

          +
          JButton createUserBtn
          +
        • +
        • +

          editBookBtn

          +
          JButton editBookBtn
          +
        • +
        • +

          editUserBtn

          +
          JButton editUserBtn
          +
        • +
        • +

          jTabbedPane

          +
          JTabbedPane jTabbedPane
          +
        • +
        • +

          mainPanel

          +
          JPanel mainPanel
          +
        • +
        • +

          nameLabel

          +
          JLabel nameLabel
          +
        • +
        • +

          rentBtn

          +
          JButton rentBtn
          +
        • +
        • +

          returnBtn

          +
          JButton returnBtn
          +
        • +
        • +

          settingsBtn

          +
          JButton settingsBtn
          +
        • +
        • +

          userBooks

          +
          JLabel userBooks
          +
        • +
        • +

          userID

          +
          JLabel userID
          +
        • +
        • +

          userLimit

          +
          JLabel userLimit
          +
        • +
        • +

          userMgtLabel

          +
          JLabel userMgtLabel
          +
        • +
        • +

          userName

          +
          JLabel userName
          +
        • +
        • +

          userPanel

          +
          JPanel userPanel
          +
        • +
        • +

          userSearch

          +
          JTextField userSearch
          +
        • +
        • +

          userSearchBtn

          +
          JButton userSearchBtn
          +
        • +
        +
      • +
      +
    • +
    • + + +

      Class libsys.NewBookDialog extends JDialog implements Serializable

      +
        +
      • +

        Serialized Fields

        +
          +
        • +

          cancelBtn

          +
          JButton cancelBtn
          +
        • +
        • +

          createBtn

          +
          JButton createBtn
          +
        • +
        • +

          statusComboBox

          +
          JComboBox<E> statusComboBox
          +
        • +
        • +

          statusLbl

          +
          JLabel statusLbl
          +
        • +
        • +

          title

          +
          JLabel title
          +
        • +
        • +

          titleLbl

          +
          JLabel titleLbl
          +
        • +
        • +

          titleTxtField

          +
          JTextField titleTxtField
          +
        • +
        • +

          returnStatus

          +
          int returnStatus
          +
        • +
        • +

          name

          +
          String name
          +
        • +
        • +

          status

          +
          String status
          +
        • +
        • +

          statusOptions

          +
          String[] statusOptions
          +
        • +
        +
      • +
      +
    • +
    • + + +

      Class libsys.NewUserDialog extends JDialog implements Serializable

      +
        +
      • +

        Serialized Fields

        +
          +
        • +

          cancelBtn

          +
          JButton cancelBtn
          +
        • +
        • +

          createBtn

          +
          JButton createBtn
          +
        • +
        • +

          errorLbl

          +
          JLabel errorLbl
          +
        • +
        • +

          limitLbl

          +
          JLabel limitLbl
          +
        • +
        • +

          limitTxtField

          +
          JTextField limitTxtField
          +
        • +
        • +

          nameLbl

          +
          JLabel nameLbl
          +
        • +
        • +

          nameTxtField

          +
          JTextField nameTxtField
          +
        • +
        • +

          title

          +
          JLabel title
          +
        • +
        • +

          returnStatus

          +
          int returnStatus
          +
        • +
        • +

          name

          +
          String name
          +
        • +
        • +

          limit

          +
          int limit
          +
        • +
        +
      • +
      +
    • +
    • + + +

      Class libsys.RentDialog extends JDialog implements Serializable

      +
        +
      • +

        Serialized Fields

        +
          +
        • +

          handler

          +
          libsys.Handler handler
          +
        • +
        • +

          cancelButton

          +
          JButton cancelButton
          +
        • +
        • +

          givenBookId

          +
          JTextField givenBookId
          +
        • +
        • +

          invalidLabel

          +
          JLabel invalidLabel
          +
        • +
        • +

          label

          +
          JLabel label
          +
        • +
        • +

          okButton

          +
          JButton okButton
          +
        • +
        • +

          returnStatus

          +
          int returnStatus
          +
        • +
        +
      • +
      +
    • +
    • + + +

      Class libsys.ReturnDialog extends JDialog implements Serializable

      +
        +
      • +

        Serialized Fields

        +
          +
        • +

          handler

          +
          libsys.Handler handler
          +
        • +
        • +

          id

          +
          int id
          +
        • +
        • +

          cancelButton

          +
          JButton cancelButton
          +
        • +
        • +

          givenBookId

          +
          JTextField givenBookId
          +
        • +
        • +

          invalidLabel

          +
          JLabel invalidLabel
          +
        • +
        • +

          label

          +
          JLabel label
          +
        • +
        • +

          okButton

          +
          JButton okButton
          +
        • +
        • +

          returnStatus

          +
          int returnStatus
          +
        • +
        +
      • +
      +
    • +
    • + + +

      Class libsys.SettingsDialog extends JDialog implements Serializable

      +
        +
      • +

        Serialized Fields

        +
          +
        • +

          booksFilenameLbl

          +
          JLabel booksFilenameLbl
          +
        • +
        • +

          booksFilenameTxt

          +
          JTextField booksFilenameTxt
          +
        • +
        • +

          discardBtn

          +
          JButton discardBtn
          +
        • +
        • +

          saveBtn

          +
          JButton saveBtn
          +
        • +
        • +

          settingsLbl

          +
          JLabel settingsLbl
          +
        • +
        • +

          titleLbl

          +
          JLabel titleLbl
          +
        • +
        • +

          titleTxtField

          +
          JTextField titleTxtField
          +
        • +
        • +

          usersFilenameLbl

          +
          JLabel usersFilenameLbl
          +
        • +
        • +

          usersFilenameTxt

          +
          JTextField usersFilenameTxt
          +
        • +
        • +

          returnStatus

          +
          int returnStatus
          +
        • +
        • +

          title

          +
          String title
          +
        • +
        • +

          usersFilename

          +
          String usersFilename
          +
        • +
        • +

          booksFilename

          +
          String booksFilename
          +
        • +
        • +

          preset

          +
          Settings preset
          +
        • +
        +
      • +
      +
    • +
    +
  • +
+
+ + + + +

Copyright © 2017. All rights reserved.

+ + diff --git a/docs/stylesheet.css b/docs/stylesheet.css new file mode 100644 index 0000000..98055b2 --- /dev/null +++ b/docs/stylesheet.css @@ -0,0 +1,574 @@ +/* Javadoc style sheet */ +/* +Overall document style +*/ + +@import url('resources/fonts/dejavu.css'); + +body { + background-color:#ffffff; + color:#353833; + font-family:'DejaVu Sans', Arial, Helvetica, sans-serif; + font-size:14px; + margin:0; +} +a:link, a:visited { + text-decoration:none; + color:#4A6782; +} +a:hover, a:focus { + text-decoration:none; + color:#bb7a2a; +} +a:active { + text-decoration:none; + color:#4A6782; +} +a[name] { + color:#353833; +} +a[name]:hover { + text-decoration:none; + color:#353833; +} +pre { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; +} +h1 { + font-size:20px; +} +h2 { + font-size:18px; +} +h3 { + font-size:16px; + font-style:italic; +} +h4 { + font-size:13px; +} +h5 { + font-size:12px; +} +h6 { + font-size:11px; +} +ul { + list-style-type:disc; +} +code, tt { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; + margin-top:8px; + line-height:1.4em; +} +dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; +} +table tr td dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + vertical-align:top; + padding-top:4px; +} +sup { + font-size:8px; +} +/* +Document title and Copyright styles +*/ +.clear { + clear:both; + height:0px; + overflow:hidden; +} +.aboutLanguage { + float:right; + padding:0px 21px; + font-size:11px; + z-index:200; + margin-top:-9px; +} +.legalCopy { + margin-left:.5em; +} +.bar a, .bar a:link, .bar a:visited, .bar a:active { + color:#FFFFFF; + text-decoration:none; +} +.bar a:hover, .bar a:focus { + color:#bb7a2a; +} +.tab { + background-color:#0066FF; + color:#ffffff; + padding:8px; + width:5em; + font-weight:bold; +} +/* +Navigation bar styles +*/ +.bar { + background-color:#4D7A97; + color:#FFFFFF; + padding:.8em .5em .4em .8em; + height:auto;/*height:1.8em;*/ + font-size:11px; + margin:0; +} +.topNav { + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.bottomNav { + margin-top:10px; + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.subNav { + background-color:#dee3e9; + float:left; + width:100%; + overflow:hidden; + font-size:12px; +} +.subNav div { + clear:left; + float:left; + padding:0 0 5px 6px; + text-transform:uppercase; +} +ul.navList, ul.subNavList { + float:left; + margin:0 25px 0 0; + padding:0; +} +ul.navList li{ + list-style:none; + float:left; + padding: 5px 6px; + text-transform:uppercase; +} +ul.subNavList li{ + list-style:none; + float:left; +} +.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { + color:#FFFFFF; + text-decoration:none; + text-transform:uppercase; +} +.topNav a:hover, .bottomNav a:hover { + text-decoration:none; + color:#bb7a2a; + text-transform:uppercase; +} +.navBarCell1Rev { + background-color:#F8981D; + color:#253441; + margin: auto 5px; +} +.skipNav { + position:absolute; + top:auto; + left:-9999px; + overflow:hidden; +} +/* +Page header and footer styles +*/ +.header, .footer { + clear:both; + margin:0 20px; + padding:5px 0 0 0; +} +.indexHeader { + margin:10px; + position:relative; +} +.indexHeader span{ + margin-right:15px; +} +.indexHeader h1 { + font-size:13px; +} +.title { + color:#2c4557; + margin:10px 0; +} +.subTitle { + margin:5px 0 0 0; +} +.header ul { + margin:0 0 15px 0; + padding:0; +} +.footer ul { + margin:20px 0 5px 0; +} +.header ul li, .footer ul li { + list-style:none; + font-size:13px; +} +/* +Heading styles +*/ +div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList ul.blockList li.blockList h3 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList li.blockList h3 { + padding:0; + margin:15px 0; +} +ul.blockList li.blockList h2 { + padding:0px 0 20px 0; +} +/* +Page layout container styles +*/ +.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer { + clear:both; + padding:10px 20px; + position:relative; +} +.indexContainer { + margin:10px; + position:relative; + font-size:12px; +} +.indexContainer h2 { + font-size:13px; + padding:0 0 3px 0; +} +.indexContainer ul { + margin:0; + padding:0; +} +.indexContainer ul li { + list-style:none; + padding-top:2px; +} +.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { + font-size:12px; + font-weight:bold; + margin:10px 0 0 0; + color:#4E4E4E; +} +.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { + margin:5px 0 10px 0px; + font-size:14px; + font-family:'DejaVu Sans Mono',monospace; +} +.serializedFormContainer dl.nameValue dt { + margin-left:1px; + font-size:1.1em; + display:inline; + font-weight:bold; +} +.serializedFormContainer dl.nameValue dd { + margin:0 0 0 1px; + font-size:1.1em; + display:inline; +} +/* +List styles +*/ +ul.horizontal li { + display:inline; + font-size:0.9em; +} +ul.inheritance { + margin:0; + padding:0; +} +ul.inheritance li { + display:inline; + list-style:none; +} +ul.inheritance li ul.inheritance { + margin-left:15px; + padding-left:15px; + padding-top:1px; +} +ul.blockList, ul.blockListLast { + margin:10px 0 10px 0; + padding:0; +} +ul.blockList li.blockList, ul.blockListLast li.blockList { + list-style:none; + margin-bottom:15px; + line-height:1.4; +} +ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { + padding:0px 20px 5px 10px; + border:1px solid #ededed; + background-color:#f8f8f8; +} +ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { + padding:0 0 5px 8px; + background-color:#ffffff; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { + margin-left:0; + padding-left:0; + padding-bottom:15px; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { + list-style:none; + border-bottom:none; + padding-bottom:0; +} +table tr td dl, table tr td dl dt, table tr td dl dd { + margin-top:0; + margin-bottom:1px; +} +/* +Table styles +*/ +.overviewSummary, .memberSummary, .typeSummary, .useSummary, .constantsSummary, .deprecatedSummary { + width:100%; + border-left:1px solid #EEE; + border-right:1px solid #EEE; + border-bottom:1px solid #EEE; +} +.overviewSummary, .memberSummary { + padding:0px; +} +.overviewSummary caption, .memberSummary caption, .typeSummary caption, +.useSummary caption, .constantsSummary caption, .deprecatedSummary caption { + position:relative; + text-align:left; + background-repeat:no-repeat; + color:#253441; + font-weight:bold; + clear:none; + overflow:hidden; + padding:0px; + padding-top:10px; + padding-left:1px; + margin:0px; + white-space:pre; +} +.overviewSummary caption a:link, .memberSummary caption a:link, .typeSummary caption a:link, +.useSummary caption a:link, .constantsSummary caption a:link, .deprecatedSummary caption a:link, +.overviewSummary caption a:hover, .memberSummary caption a:hover, .typeSummary caption a:hover, +.useSummary caption a:hover, .constantsSummary caption a:hover, .deprecatedSummary caption a:hover, +.overviewSummary caption a:active, .memberSummary caption a:active, .typeSummary caption a:active, +.useSummary caption a:active, .constantsSummary caption a:active, .deprecatedSummary caption a:active, +.overviewSummary caption a:visited, .memberSummary caption a:visited, .typeSummary caption a:visited, +.useSummary caption a:visited, .constantsSummary caption a:visited, .deprecatedSummary caption a:visited { + color:#FFFFFF; +} +.overviewSummary caption span, .memberSummary caption span, .typeSummary caption span, +.useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + padding-bottom:7px; + display:inline-block; + float:left; + background-color:#F8981D; + border: none; + height:16px; +} +.memberSummary caption span.activeTableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#F8981D; + height:16px; +} +.memberSummary caption span.tableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#4D7A97; + height:16px; +} +.memberSummary caption span.tableTab, .memberSummary caption span.activeTableTab { + padding-top:0px; + padding-left:0px; + padding-right:0px; + background-image:none; + float:none; + display:inline; +} +.overviewSummary .tabEnd, .memberSummary .tabEnd, .typeSummary .tabEnd, +.useSummary .tabEnd, .constantsSummary .tabEnd, .deprecatedSummary .tabEnd { + display:none; + width:5px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .activeTableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .tableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + background-color:#4D7A97; + float:left; + +} +.overviewSummary td, .memberSummary td, .typeSummary td, +.useSummary td, .constantsSummary td, .deprecatedSummary td { + text-align:left; + padding:0px 0px 12px 10px; +} +th.colOne, th.colFirst, th.colLast, .useSummary th, .constantsSummary th, +td.colOne, td.colFirst, td.colLast, .useSummary td, .constantsSummary td{ + vertical-align:top; + padding-right:0px; + padding-top:8px; + padding-bottom:3px; +} +th.colFirst, th.colLast, th.colOne, .constantsSummary th { + background:#dee3e9; + text-align:left; + padding:8px 3px 3px 7px; +} +td.colFirst, th.colFirst { + white-space:nowrap; + font-size:13px; +} +td.colLast, th.colLast { + font-size:13px; +} +td.colOne, th.colOne { + font-size:13px; +} +.overviewSummary td.colFirst, .overviewSummary th.colFirst, +.useSummary td.colFirst, .useSummary th.colFirst, +.overviewSummary td.colOne, .overviewSummary th.colOne, +.memberSummary td.colFirst, .memberSummary th.colFirst, +.memberSummary td.colOne, .memberSummary th.colOne, +.typeSummary td.colFirst{ + width:25%; + vertical-align:top; +} +td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { + font-weight:bold; +} +.tableSubHeadingColor { + background-color:#EEEEFF; +} +.altColor { + background-color:#FFFFFF; +} +.rowColor { + background-color:#EEEEEF; +} +/* +Content styles +*/ +.description pre { + margin-top:0; +} +.deprecatedContent { + margin:0; + padding:10px 0; +} +.docSummary { + padding:0; +} + +ul.blockList ul.blockList ul.blockList li.blockList h3 { + font-style:normal; +} + +div.block { + font-size:14px; + font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; +} + +td.colLast div { + padding-top:0px; +} + + +td.colLast a { + padding-bottom:3px; +} +/* +Formatting effect styles +*/ +.sourceLineNo { + color:green; + padding:0 30px 0 0; +} +h1.hidden { + visibility:hidden; + overflow:hidden; + font-size:10px; +} +.block { + display:block; + margin:3px 10px 2px 0px; + color:#474747; +} +.deprecatedLabel, .descfrmTypeLabel, .memberNameLabel, .memberNameLink, +.overrideSpecifyLabel, .packageHierarchyLabel, .paramLabel, .returnLabel, +.seeLabel, .simpleTagLabel, .throwsLabel, .typeNameLabel, .typeNameLink { + font-weight:bold; +} +.deprecationComment, .emphasizedPhrase, .interfaceName { + font-style:italic; +} + +div.block div.block span.deprecationComment, div.block div.block span.emphasizedPhrase, +div.block div.block span.interfaceName { + font-style:normal; +} + +div.contentContainer ul.blockList li.blockList h2{ + padding-bottom:0px; +} diff --git a/src/main/java/libsys/Book.java b/src/main/java/libsys/Book.java index db124c4..b5e3a4e 100644 --- a/src/main/java/libsys/Book.java +++ b/src/main/java/libsys/Book.java @@ -1,28 +1,32 @@ package libsys; /* * Written by : Bin Hong Lee - * Last edited : 5/30/2017 + * Last edited : 6/4/2017 */ -class Book +public class Book { - //Declaring variable storages - //Book title private String title; - //Book ID private int id; - //( AVAILABLE || RENTED || RESERVED || NOT AVAILABLE) private String status; - //Book due date private int[] dueDate = new int[3]; - //Constructor without book title + /** + * Create new Book with given id (Usually used as placeholders) + * @param id Identification number of the Book + */ public Book(int id) { this.id = id; this.status = "NOT AVAILABLE"; } + /** + * Create new Book with given title, id and status (Usually used for new Book creation) + * @param title Title of the Book + * @param id Identification number of the Book + * @param status Status of the Book + */ public Book(String title, int id, String status) { this.title = title; @@ -30,6 +34,13 @@ class Book this.status = status; } + /** + * Create new Book with given id, title, status and dueDate (Usually used for initialization from database) + * @param id Identification number of the Book + * @param title Title of the Book + * @param status Status of the Book + * @param dueDate Due date of the Book + */ public Book(int id, String title, String status, int[] dueDate) { this.title = title; @@ -38,7 +49,10 @@ class Book this.dueDate = dueDate; } - //Getters and setters + /** + * Returns the title of the Book + * @return title + */ public String getTitle() { if (title!=null) @@ -49,27 +63,47 @@ class Book } } + /** + * Returns the status of the Book + * @return status (AVAILABLE || RENTED || RESERVED || NOT AVAILABLE) + */ public String getStatus() { return status; } + /** + * Returns the id of the Book + * @return id + */ public int getId() { return id; } + /** + * Returns the due date of the Book + * @return due date ([yyyy][mm][dd]) + */ public int[] getDueDate() { return dueDate; } + /** + * Set the title to the given title + * @param title The new title of the Book + */ public void setTitle(String title) { this.title = title; } - //Call to rent book, return if renting is successful + /** + * Call to rent book, return if renting is successful + * @param dueDate The new due date of the Book + * @return if renting is successful + */ public boolean rent(int[] dueDate) { //Check if the book is available to be rented @@ -85,14 +119,20 @@ class Book return true; } - //Call to return the book + /** + * Return the Book to the shelf + */ public void returned() { //Update book status status = "AVAILABLE"; } - //Calculate the overdue fine + /** + * Calculate the overdue fine + * @param currentDay Today's date + * @return Price of the fine + */ public double overdueFine(int[] currentDay) { double fine; diff --git a/src/main/java/libsys/BookFactory.java b/src/main/java/libsys/BookFactory.java index 4cbaa08..89158d4 100644 --- a/src/main/java/libsys/BookFactory.java +++ b/src/main/java/libsys/BookFactory.java @@ -1,7 +1,7 @@ package libsys; /* * Written by : Bin Hong Lee - * Last edited : 5/30/2017 + * Last edited : 6/4/2017 */ import java.util.List; @@ -16,17 +16,25 @@ import java.io.File; import java.util.Enumeration; import java.io.Serializable; -class BookFactory +public class BookFactory { private List books = new ArrayList(); private int id; private String bookFilename; + /** + * Create a new empty BookFactory + */ public BookFactory() { id = 0; + bookFilename = "books.json"; } + /** + * Create a new BookFactory and fill it with information from a JSON file + * @param bookFilename Name of the input JSON file + */ public BookFactory(String bookFilename) { try @@ -51,16 +59,20 @@ class BookFactory books.add(new Book(id, title, status, dueDate)); } in.close(); + id = books.get(books.size() - 1).getId() + 1; } catch (Exception ex) { System.out.println(ex.getMessage()); + id = 0; } this.bookFilename = bookFilename; - id = books.get(books.size() - 1).getId() + 1; } + /** + * Output the data into a JSON file replacing the input file (or if filename not given, "books.json") + */ public void toJsonFile() { try @@ -86,11 +98,21 @@ class BookFactory } } + /** + * Update the output filename for the object + * @param bookFilename The new filename + */ public void setBookFileName(String bookFilename) { this.bookFilename = bookFilename; } + /** + * Adds a new Book into this class + * @param title Title of the Book + * @param status Status of the Book + * @return The new Book that is just created + */ public Book newBook(String title, String status) { Book temp = new Book(title, id, status); @@ -102,12 +124,24 @@ class BookFactory return temp; } + /** + * Looks for a Book with the given id + * @param index id of the Book to be found + * @return Book with the given id + */ public Book getBook(int index) { return search(index, 0, books.size() - 1); } - public Book search(int index, int start, int end) + /** + * Recursive binary search through the array list for the Book with the given id + * @param index id of the Book to be found + * @param start Starting point to search + * @param end Ending point to search + * @return Book with the given id + */ + private Book search(int index, int start, int end) { if (start == end && books.get(start).getId() == index) { @@ -135,6 +169,11 @@ class BookFactory } } + /** + * Linear search through the array list for Book with the given Title + * @param title Title of the Book to be found + * @return Book with the given title + */ public Book getBook(String title) { for (int i = 0; i < books.size(); i++) @@ -150,8 +189,14 @@ class BookFactory throw new NullPointerException(); } + /** + * Replacing a Book in the array list with a new Book + * @param oldBook Book to be replaced + * @param newBook Book replacing it + */ public void update(Book oldBook, Book newBook) { + boolean found = false; for (int i = 0; i < books.size(); i++) { Book temp = books.get(i); @@ -159,9 +204,15 @@ class BookFactory if(temp.getId() == oldBook.getId()) { books.set(i, newBook); + found = true; } } + if (!found) + { + throw new NullPointerException(); + } + toJsonFile(); } } diff --git a/src/main/java/libsys/EditBookDialog.java b/src/main/java/libsys/EditBookDialog.java index 99b42a2..a127fe5 100644 --- a/src/main/java/libsys/EditBookDialog.java +++ b/src/main/java/libsys/EditBookDialog.java @@ -1,7 +1,18 @@ package libsys; +/* + * Written by : Bin Hong Lee + * Last edited : 6/4/2017 + */ +@SuppressWarnings({"unchecked", "serial"}) public class EditBookDialog extends javax.swing.JDialog { + /** + * Create new EditBookDialog + * @param parent java.awt.Frame + * @param modal boolean + * @param book Book + */ public EditBookDialog(java.awt.Frame parent, boolean modal, Book book) { super(parent, modal); initComponents(); @@ -9,7 +20,6 @@ public class EditBookDialog extends javax.swing.JDialog { init(); } - @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { @@ -113,7 +123,7 @@ public class EditBookDialog extends javax.swing.JDialog { statusLbl.setText("Status : " + book.getStatus()); nameTxtField.setText(book.getTitle()); } - + private void doClose(boolean toReturn) { if (toReturn) @@ -124,12 +134,20 @@ public class EditBookDialog extends javax.swing.JDialog { setVisible(false); dispose(); } - + + /** + * Returns the name from the nameTxtField + * @return new Book name + */ public String getNewName() { return newName; } - + + /** + * Returns if the user selected "Save" or "Cancel" + * @return T:"Save"|F:"Cancel" + */ public boolean getReturnStatus() { return returnStatus; diff --git a/src/main/java/libsys/EditUserDialog.java b/src/main/java/libsys/EditUserDialog.java index b3b3c3a..d8a2acf 100644 --- a/src/main/java/libsys/EditUserDialog.java +++ b/src/main/java/libsys/EditUserDialog.java @@ -1,9 +1,18 @@ package libsys; +/* + * Written by : Bin Hong Lee + * Last edited : 6/4/2017 + */ +@SuppressWarnings({"unchecked", "serial"}) public class EditUserDialog extends javax.swing.JDialog { /** - * Creates new form EditUserDialog + * Creates new EditUserDialog + * @param parent java.awt.Frame + * @param modal boolean + * @param user User + * @param books BookFactory */ public EditUserDialog(java.awt.Frame parent, boolean modal, User user, BookFactory books) { super(parent, modal); @@ -13,12 +22,6 @@ public class EditUserDialog extends javax.swing.JDialog { init(); } - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { @@ -141,7 +144,7 @@ public class EditUserDialog extends javax.swing.JDialog { limitTxtField.setText(String.valueOf(user.getLimit())); nameTxtField.setText(user.getName()); } - + private void doClose(boolean toReturn) { if (toReturn) @@ -161,17 +164,29 @@ public class EditUserDialog extends javax.swing.JDialog { setVisible(false); dispose(); } - + + /** + * Returns if the user selected "Save" or "Cancel" + * @return T:"Save"|F:"Cancel" + */ public boolean getReturnStatus() { return returnStatus; } - + + /** + * Returns the name from the nameTxtField + * @return new User name + */ public String getNewName() { return newName; } - + + /** + * Returns the limit from the limitTxtField + * @return new User limit + */ public int getNewLimit() { return newLimit; diff --git a/src/main/java/libsys/Handler.java b/src/main/java/libsys/Handler.java index cbb1d18..1a33bee 100644 --- a/src/main/java/libsys/Handler.java +++ b/src/main/java/libsys/Handler.java @@ -1,7 +1,7 @@ package libsys; /* * Written by : Bin Hong Lee - * Last edited : 5/28/2017 + * Last edited : 6/4/2017 */ import java.util.Calendar; @@ -14,11 +14,20 @@ class Handler UserFactory users; Calendar cal = Calendar.getInstance(); + /** + * Creates new empty Handler + */ public Handler() { } + /** + * Given User borrows the given Book + * @param user User borrowing the Book + * @param book Book to be borrowed + * @return If the borrow operation is successful + */ public boolean borrowBook(User user, Book book) { User newUser = user; @@ -35,6 +44,12 @@ class Handler return false; } + /** + * Given User returns the given Book + * @param user User returning the Book + * @param book Book to be returned + * @return If the return operation is successful + */ public boolean returnBook(User user, Book book) { User newUser = user; @@ -53,6 +68,11 @@ class Handler return false; } + /** + * Calculating the due date + * @param days Amount of days to be borrowed + * @return Amount of days added to the current day + */ public int[] calDueDate(int days) { int[] dueDate = currentDay(); @@ -122,7 +142,11 @@ class Handler return dueDate; } - public int[] currentDay() + /** + * Returns the current date in an int array + * @return date in ([YYYY][MM][DD]) format + */ + private int[] currentDay() { int[] currentDay = new int[3]; @@ -133,6 +157,11 @@ class Handler return currentDay; } + /** + * Create a String of all book titles with the given Book ids + * @param bookIDs Array of Book ids + * @return String of book titles seperated with "; " + */ public String bookIdsToTitlesString(int[] bookIDs) { String titlesString = ""; diff --git a/src/main/java/libsys/Main.java b/src/main/java/libsys/Main.java index 08751db..e3d3cf2 100644 --- a/src/main/java/libsys/Main.java +++ b/src/main/java/libsys/Main.java @@ -1,15 +1,19 @@ package libsys; /* * Written by : Bin Hong Lee - * Last edited : 6/2/2017 + * Last edited : 6/4/2017 */ -class Main +public class Main { static Settings settings = new Settings("settings.txt"); static String bookFilename = settings.get("Books Filename"); static String userFilename = settings.get("Users Filename"); + /** + * Start the applicationn + * @param args + */ public static void main(String[] args) { Handler handler = new Handler(); diff --git a/src/main/java/libsys/MainGUI.java b/src/main/java/libsys/MainGUI.java index 8752513..4c910a7 100644 --- a/src/main/java/libsys/MainGUI.java +++ b/src/main/java/libsys/MainGUI.java @@ -1,11 +1,14 @@ package libsys; +/* + * Written by : Bin Hong Lee + * Last edited : 6/4/2017 + */ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.concurrent.CountDownLatch; @SuppressWarnings({"unchecked", "serial"}) - public class MainGUI extends javax.swing.JFrame { Handler handler; @@ -15,6 +18,11 @@ public class MainGUI extends javax.swing.JFrame boolean bookExist = false; boolean userExist = false; + /** + * Creates a new MainGUI + * @param handler Given Handler from Main + * @param settings Given Settings from Main + */ public MainGUI(Handler handler, Settings settings) { this.handler = handler; @@ -314,9 +322,9 @@ public class MainGUI extends javax.swing.JFrame if (settingsUI.getReturnStatus() != -1) { - settings.update(settings.getKey(0), settingsUI.getTitle()); - settings.update(settings.getKey(1), settingsUI.getUsersFilename()); - settings.update(settings.getKey(2), settingsUI.getBooksFilename()); + settings.setTitle(settingsUI.getTitle()); + settings.setUsersFilename(settingsUI.getUsersFilename()); + settings.setBooksFilename(settingsUI.getBooksFilename()); nameLabel.setText(settingsUI.getTitle()); } }//GEN-LAST:event_settingsBtnActionPerformed @@ -338,7 +346,7 @@ public class MainGUI extends javax.swing.JFrame if (newBookUI.getReturnStatus() != -1) { - bookSearch.setText(String.valueOf(handler.books.newBook(newBookUI.getName(), newBookUI.getStatus()).getId())); + bookSearch.setText(String.valueOf(handler.books.newBook(newBookUI.getTitle(), newBookUI.getStatus()).getId())); bookSearchBtnActionPerformed(evt); } }//GEN-LAST:event_createBookBtnActionPerformed @@ -346,14 +354,14 @@ public class MainGUI extends javax.swing.JFrame private void editUserBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editUserBtnActionPerformed EditUserDialog editUserDialog = new EditUserDialog(this, true, user, handler.books); editUserDialog.setVisible(true); - + if (editUserDialog.getReturnStatus()) { User newUser = user; user.setName(editUserDialog.getNewName()); user.setLimit(editUserDialog.getNewLimit()); } - + userSearchBtnActionPerformed(evt); }//GEN-LAST:event_editUserBtnActionPerformed @@ -387,7 +395,7 @@ public class MainGUI extends javax.swing.JFrame private void editBookBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editBookBtnActionPerformed EditBookDialog editBookDialog = new EditBookDialog(this, true, book); editBookDialog.setVisible(true); - + if (editBookDialog.getReturnStatus()) { Book newBook = book; diff --git a/src/main/java/libsys/NewBookDialog.java b/src/main/java/libsys/NewBookDialog.java index 5677c2b..75fb3a3 100644 --- a/src/main/java/libsys/NewBookDialog.java +++ b/src/main/java/libsys/NewBookDialog.java @@ -1,11 +1,16 @@ package libsys; +/* + * Written by : Bin Hong Lee + * Last edited : 6/4/2017 + */ +@SuppressWarnings({"unchecked", "serial", "rawtypes"}) public class NewBookDialog extends javax.swing.JDialog { /** * Creates new form NewBookDialog - * @param parent - * @param modal + * @param parent java.awt.Frame + * @param modal boolean */ public NewBookDialog(java.awt.Frame parent, boolean modal) { super(parent, modal); @@ -13,28 +18,30 @@ public class NewBookDialog extends javax.swing.JDialog { } /** - * @return the return status of this dialog - one of RET_OK or RET_CANCEL + * Get the return status + * @return -1:Cancel|1:Create */ public int getReturnStatus() { return returnStatus; } - @Override - public String getName() { + /** + * Get the name of the new Book + * @return name from titleTxtField + */ + public String getTitle() { return name; } + /** + * Get the status of the new Book + * @return status from statusComboBox + */ public String getStatus() { return status; } - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { @@ -134,49 +141,6 @@ public class NewBookDialog extends javax.swing.JDialog { dispose(); } - /** - * @param args the command line arguments - */ - public static void main(String args[]) { - /* Set the Nimbus look and feel */ - // - /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. - * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html - */ - try { - for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { - if ("Nimbus".equals(info.getName())) { - javax.swing.UIManager.setLookAndFeel(info.getClassName()); - break; - } - } - } catch (ClassNotFoundException ex) { - java.util.logging.Logger.getLogger(NewBookDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (InstantiationException ex) { - java.util.logging.Logger.getLogger(NewBookDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (IllegalAccessException ex) { - java.util.logging.Logger.getLogger(NewBookDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (javax.swing.UnsupportedLookAndFeelException ex) { - java.util.logging.Logger.getLogger(NewBookDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } - // - - /* Create and display the dialog */ - java.awt.EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - NewBookDialog dialog = new NewBookDialog(new javax.swing.JFrame(), true); - dialog.addWindowListener(new java.awt.event.WindowAdapter() { - @Override - public void windowClosing(java.awt.event.WindowEvent e) { - System.exit(0); - } - }); - dialog.setVisible(true); - } - }); - } - // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton cancelBtn; private javax.swing.JButton createBtn; diff --git a/src/main/java/libsys/NewUserDialog.java b/src/main/java/libsys/NewUserDialog.java index aa657a1..ed961bc 100644 --- a/src/main/java/libsys/NewUserDialog.java +++ b/src/main/java/libsys/NewUserDialog.java @@ -1,9 +1,16 @@ package libsys; +/* + * Written by : Bin Hong Lee + * Last edited : 6/4/2017 + */ +@SuppressWarnings({"unchecked", "serial"}) public class NewUserDialog extends javax.swing.JDialog { /** * Creates new form NewUserDialog + * @param parent java.awt.Frame + * @param modal boolean */ public NewUserDialog(java.awt.Frame parent, boolean modal) { super(parent, modal); @@ -11,27 +18,30 @@ public class NewUserDialog extends javax.swing.JDialog { } /** - * @return the return status of this dialog - one of RET_OK or RET_CANCEL + * Get the return status + * @return -1:Cancel|1:Create */ public int getReturnStatus() { return returnStatus; } + /** + * Get the name of the new User + * @return name from nameTxtField + */ public String getName() { return name; } + /** + * Get the limit of the new User + * @return limit from limitTxtField + */ public int getLimit() { return limit; } - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { @@ -144,48 +154,6 @@ public class NewUserDialog extends javax.swing.JDialog { dispose(); } - /** - * @param args the command line arguments - */ - public static void main(String args[]) { - /* Set the Nimbus look and feel */ - // - /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. - * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html - */ - try { - for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { - if ("Nimbus".equals(info.getName())) { - javax.swing.UIManager.setLookAndFeel(info.getClassName()); - break; - } - } - } catch (ClassNotFoundException ex) { - java.util.logging.Logger.getLogger(NewUserDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (InstantiationException ex) { - java.util.logging.Logger.getLogger(NewUserDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (IllegalAccessException ex) { - java.util.logging.Logger.getLogger(NewUserDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (javax.swing.UnsupportedLookAndFeelException ex) { - java.util.logging.Logger.getLogger(NewUserDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } - // - - /* Create and display the dialog */ - java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { - NewUserDialog dialog = new NewUserDialog(new javax.swing.JFrame(), true); - dialog.addWindowListener(new java.awt.event.WindowAdapter() { - @Override - public void windowClosing(java.awt.event.WindowEvent e) { - System.exit(0); - } - }); - dialog.setVisible(true); - } - }); - } - // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton cancelBtn; private javax.swing.JButton createBtn; diff --git a/src/main/java/libsys/RentDialog.java b/src/main/java/libsys/RentDialog.java index d0081ea..4c47fb6 100644 --- a/src/main/java/libsys/RentDialog.java +++ b/src/main/java/libsys/RentDialog.java @@ -1,4 +1,8 @@ package libsys; +/* + * Written by : Bin Hong Lee + * Last edited : 6/4/2017 + */ import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; @@ -8,16 +12,16 @@ import javax.swing.InputMap; import javax.swing.JComponent; import javax.swing.KeyStroke; +@SuppressWarnings({"unchecked", "serial"}) public class RentDialog extends javax.swing.JDialog { - static Handler handler = new Handler(); - /** - * A return status code - returned if Cancel button has been pressed - */ - public static final int RET_CANCEL = -1; + Handler handler = new Handler(); /** * Creates new form RentDialog + * @param parent java.awt.Frame + * @param modal boolean + * @param handler Handler */ public RentDialog(java.awt.Frame parent, boolean modal, Handler handler) { super(parent, modal); @@ -31,24 +35,19 @@ public class RentDialog extends javax.swing.JDialog { ActionMap actionMap = getRootPane().getActionMap(); actionMap.put(cancelName, new AbstractAction() { public void actionPerformed(ActionEvent e) { - doClose(RET_CANCEL); + doClose(-1); } }); } /** - * @return the return status of this dialog - one of RET_OK or RET_CANCEL + * Get the return status + * @return -1:Cancel|others:Book id */ public int getReturnStatus() { return returnStatus; } - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { @@ -144,64 +143,22 @@ public class RentDialog extends javax.swing.JDialog { }//GEN-LAST:event_okButtonActionPerformed private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed - doClose(RET_CANCEL); + doClose(-1); }//GEN-LAST:event_cancelButtonActionPerformed /** * Closes the dialog */ private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog - doClose(RET_CANCEL); + doClose(-1); }//GEN-LAST:event_closeDialog - + private void doClose(int retStatus) { returnStatus = retStatus; setVisible(false); dispose(); } - /** - * @param args the command line arguments - */ - public static void main(String args[]) { - /* Set the Nimbus look and feel */ - // - /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. - * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html - */ - try { - for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { - if ("Nimbus".equals(info.getName())) { - javax.swing.UIManager.setLookAndFeel(info.getClassName()); - break; - } - } - } catch (ClassNotFoundException ex) { - java.util.logging.Logger.getLogger(RentDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (InstantiationException ex) { - java.util.logging.Logger.getLogger(RentDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (IllegalAccessException ex) { - java.util.logging.Logger.getLogger(RentDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (javax.swing.UnsupportedLookAndFeelException ex) { - java.util.logging.Logger.getLogger(RentDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } - // - - /* Create and display the dialog */ - java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { - RentDialog dialog = new RentDialog(new javax.swing.JFrame(), true, handler); - dialog.addWindowListener(new java.awt.event.WindowAdapter() { - @Override - public void windowClosing(java.awt.event.WindowEvent e) { - System.exit(0); - } - }); - dialog.setVisible(true); - } - }); - } - // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton cancelButton; private javax.swing.JTextField givenBookId; @@ -210,5 +167,5 @@ public class RentDialog extends javax.swing.JDialog { private javax.swing.JButton okButton; // End of variables declaration//GEN-END:variables - private int returnStatus = RET_CANCEL; + private int returnStatus = -1; } diff --git a/src/main/java/libsys/ReturnDialog.java b/src/main/java/libsys/ReturnDialog.java index 99d7220..d5a1b97 100644 --- a/src/main/java/libsys/ReturnDialog.java +++ b/src/main/java/libsys/ReturnDialog.java @@ -1,4 +1,8 @@ package libsys; +/* + * Written by : Bin Hong Lee + * Last edited : 6/4/2017 + */ import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; @@ -8,17 +12,18 @@ import javax.swing.InputMap; import javax.swing.JComponent; import javax.swing.KeyStroke; +@SuppressWarnings({"unchecked", "serial"}) public class ReturnDialog extends javax.swing.JDialog { - static Handler handler = new Handler(); - static int id; - /** - * A return status code - returned if Cancel button has been pressed - */ - public static final int RET_CANCEL = -1; + Handler handler = new Handler(); + int id; /** - * Creates new form ReturnDialog + * Creates a new ReturnDialog + * @param parent java.awt.Frame + * @param modal boolean + * @param handler Handler + * @param id int - Returning Book's User id */ public ReturnDialog(java.awt.Frame parent, boolean modal, Handler handler, int id) { super(parent, modal); @@ -33,24 +38,19 @@ public class ReturnDialog extends javax.swing.JDialog { ActionMap actionMap = getRootPane().getActionMap(); actionMap.put(cancelName, new AbstractAction() { public void actionPerformed(ActionEvent e) { - doClose(RET_CANCEL); + doClose(-1); } }); } /** - * @return the return status of this dialog - one of RET_OK or RET_CANCEL + * Get the return status + * @return -1:Cancel|others:Book id */ public int getReturnStatus() { return returnStatus; } - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { @@ -132,7 +132,7 @@ public class ReturnDialog extends javax.swing.JDialog { { int[] borrowedList = handler.users.getUser(id).bookStatus(); boolean exist = false; - + for (int i = 0; i < borrowedList.length; i++) { if (borrowedList[i] == Integer.parseInt(givenBookId.getText())) @@ -140,7 +140,7 @@ public class ReturnDialog extends javax.swing.JDialog { exist = true; } } - + if (exist) { doClose(Integer.parseInt(givenBookId.getText())); @@ -157,14 +157,14 @@ public class ReturnDialog extends javax.swing.JDialog { }//GEN-LAST:event_okButtonActionPerformed private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed - doClose(RET_CANCEL); + doClose(-1); }//GEN-LAST:event_cancelButtonActionPerformed /** * Closes the dialog */ private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog - doClose(RET_CANCEL); + doClose(-1); }//GEN-LAST:event_closeDialog private void doClose(int retStatus) { @@ -173,48 +173,6 @@ public class ReturnDialog extends javax.swing.JDialog { dispose(); } - /** - * @param args the command line arguments - */ - public static void main(String args[]) { - /* Set the Nimbus look and feel */ - // - /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. - * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html - */ - try { - for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { - if ("Nimbus".equals(info.getName())) { - javax.swing.UIManager.setLookAndFeel(info.getClassName()); - break; - } - } - } catch (ClassNotFoundException ex) { - java.util.logging.Logger.getLogger(ReturnDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (InstantiationException ex) { - java.util.logging.Logger.getLogger(ReturnDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (IllegalAccessException ex) { - java.util.logging.Logger.getLogger(ReturnDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (javax.swing.UnsupportedLookAndFeelException ex) { - java.util.logging.Logger.getLogger(ReturnDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } - // - - /* Create and display the dialog */ - java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { - ReturnDialog dialog = new ReturnDialog(new javax.swing.JFrame(), true, handler, id); - dialog.addWindowListener(new java.awt.event.WindowAdapter() { - @Override - public void windowClosing(java.awt.event.WindowEvent e) { - System.exit(0); - } - }); - dialog.setVisible(true); - } - }); - } - // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton cancelButton; private javax.swing.JTextField givenBookId; @@ -223,5 +181,5 @@ public class ReturnDialog extends javax.swing.JDialog { private javax.swing.JButton okButton; // End of variables declaration//GEN-END:variables - private int returnStatus = RET_CANCEL; + private int returnStatus = -1; } diff --git a/src/main/java/libsys/Settings.java b/src/main/java/libsys/Settings.java index dd782f0..f061b7f 100644 --- a/src/main/java/libsys/Settings.java +++ b/src/main/java/libsys/Settings.java @@ -1,4 +1,8 @@ package libsys; +/* + * Written by : Bin Hong Lee + * Last edited : 6/4/2017 + */ import java.util.Scanner; import java.io.FileInputStream; @@ -6,12 +10,17 @@ import java.io.PrintWriter; import java.util.HashMap; import java.util.ArrayList; +@SuppressWarnings({"unchecked", "rawtypes"}) public class Settings { private HashMap items = new HashMap(); private ArrayList keys = new ArrayList(); private String settingsFileName; + /** + * Creates new Settings importing information from the given file name + * @param settingsFileName File name of existing settings stored + */ public Settings(String settingsFileName) { this.settingsFileName = settingsFileName; @@ -34,6 +43,9 @@ public class Settings } } + /** + * Save the settings to the given input file + */ public void toFile() { try @@ -52,44 +64,70 @@ public class Settings } } - public void update(String key, String newValue) - { - items.remove(key); - items.put(key, newValue); - toFile(); - } - + /** + * Amount of fields in the settings + * @return Amount of keys + */ public int size() { return keys.size(); } + /** + * Get the field name from that specific location in the array list + * @param location Location of the field in the array list + * @return The field name + */ public String getKey(int location) { return keys.get(location); } + /** + * Get the value associated to the field name + * @param key Field name + * @return Field value + */ public String get(String key) { return items.get(key); } + /** + * Change the title of the application + * @param newTitle New Title + */ public void setTitle(String newTitle) { update("Title", newTitle); } + /** + * Change the file name for the Users + * @param newUsersFilename New file name for Users + */ public void setUsersFilename(String newUsersFilename) { update("Users Filename", newUsersFilename); } + /** + * Change the file name for the Books + * @param newBooksFilename New file name for Books + */ public void setBooksFilename(String newBooksFilename) { update("Books Filename", newBooksFilename); } - public void setDefault() + private void update(String key, String newValue) + { + items.remove(key); + items.put(key, newValue); + toFile(); + } + + private void setDefault() { keys.add("Title"); items.put(keys.get(0), "Welcome to the library"); diff --git a/src/main/java/libsys/SettingsDialog.java b/src/main/java/libsys/SettingsDialog.java index 84cdb5b..9e94ff7 100644 --- a/src/main/java/libsys/SettingsDialog.java +++ b/src/main/java/libsys/SettingsDialog.java @@ -1,13 +1,17 @@ package libsys; - -/** - * - * @author BinHong Lee +/* + * Written by : Bin Hong Lee + * Last edited : 6/4/2017 */ + +@SuppressWarnings("serial") public class SettingsDialog extends javax.swing.JDialog { /** - * Creates new form SettingsDialog + * Creates new SettingsDialog + * @param parent java.awt.Frame + * @param modal boolean + * @param preset Settings */ public SettingsDialog(java.awt.Frame parent, boolean modal, Settings preset) { super(parent, modal); @@ -16,12 +20,6 @@ public class SettingsDialog extends javax.swing.JDialog { this.preset = preset; } - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { @@ -122,55 +120,13 @@ public class SettingsDialog extends javax.swing.JDialog { doClose(-1); }//GEN-LAST:event_discardBtnActionPerformed - /** - * @param args the command line arguments - */ - public static void main(String args[]) { - /* Set the Nimbus look and feel */ - // - /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. - * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html - */ - try { - for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { - if ("Nimbus".equals(info.getName())) { - javax.swing.UIManager.setLookAndFeel(info.getClassName()); - break; - } - } - } catch (ClassNotFoundException ex) { - java.util.logging.Logger.getLogger(SettingsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (InstantiationException ex) { - java.util.logging.Logger.getLogger(SettingsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (IllegalAccessException ex) { - java.util.logging.Logger.getLogger(SettingsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (javax.swing.UnsupportedLookAndFeelException ex) { - java.util.logging.Logger.getLogger(SettingsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } - // - - /* Create and display the dialog */ - java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { - SettingsDialog dialog = new SettingsDialog(new javax.swing.JFrame(), true, preset); - dialog.addWindowListener(new java.awt.event.WindowAdapter() { - @Override - public void windowClosing(java.awt.event.WindowEvent e) { - System.exit(0); - } - }); - dialog.setVisible(true); - } - }); - } - private void setup(Settings preset) { titleTxtField.setText(preset.get(preset.getKey(0))); usersFilenameTxt.setText((preset.get(preset.getKey(1)))); booksFilenameTxt.setText(preset.get(preset.getKey(2))); } - + private void doClose(int retStatus) { returnStatus = retStatus; @@ -179,27 +135,43 @@ public class SettingsDialog extends javax.swing.JDialog { booksFilename = booksFilenameTxt.getText(); setVisible(false); } - + + /** + * Get the new title for the MainGUi + * @return Get title from titleTxtField + */ public String getTitle() { return title; } - + + /** + * Get the new Users file name + * @return Users file name from usersFilenameTxt + */ public String getUsersFilename() { return usersFilename; } - + + /** + * Get the new Books file name + * @return Books file name from booksFilenameTxt + */ public String getBooksFilename() { return booksFilename; } - + + /** + * Get the return status + * @return -1:Discard|1:Save + */ public int getReturnStatus() { return returnStatus; } - + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel booksFilenameLbl; private javax.swing.JTextField booksFilenameTxt; @@ -211,10 +183,10 @@ public class SettingsDialog extends javax.swing.JDialog { private javax.swing.JLabel usersFilenameLbl; private javax.swing.JTextField usersFilenameTxt; // End of variables declaration//GEN-END:variables - + private int returnStatus; private String title; private String usersFilename; private String booksFilename; - private static Settings preset; + private Settings preset; } diff --git a/src/main/java/libsys/User.java b/src/main/java/libsys/User.java index 37b2463..50a7d47 100644 --- a/src/main/java/libsys/User.java +++ b/src/main/java/libsys/User.java @@ -1,18 +1,24 @@ package libsys; /* * Written by : Bin Hong Lee - * Last edited : 6/3/2017 + * Last edited : 6/4/2017 */ import java.util.*; -class User +public class User { private String name; private int id; private int limit; private List books = new ArrayList(); + /** + * Creates a new User with name, id and limit (usually used to add new User) + * @param name Name of this User + * @param id id of this User + * @param limit Limit of Book this User can borrow + */ public User(String name, int id, int limit) { this.name = name; @@ -20,6 +26,13 @@ class User this.limit = limit; } + /** + * Creates a new User with name, id, limit and books (usually used to initialize from database) + * @param name Name of this User + * @param id id of this User + * @param limit Limit of Book this User can borrow + * @param books ArrayList of Book ids borrowed by the User + */ public User(String name, int id, int limit, ArrayList books) { this.name = name; @@ -28,31 +41,55 @@ class User this.books = books; } + /** + * Gets name of this User + * @return Name + */ public String getName() { return name; } + /** + * Gets id of this User + * @return id + */ public int getId() { return id; } + /** + * Gets limit of Book this User can borrow + * @return Book borrowing limit + */ public int getLimit() { return limit; } + /** + * Change name of this User + * @param name New name of the User + */ public void setName(String name) { this.name = name; } + /** + * Change limit of this User + * @param limit New limit of the User + */ public void setLimit(int limit) { this.limit = limit; } + /** + * Check status of the User + * @return If the User is already at the borrowing limit + */ public boolean status() { if (books.size() < limit) @@ -63,6 +100,10 @@ class User return false; } + /** + * Get Book ids of the books + * @return Array of Book ids borrowed by this User + */ public int[] bookStatus() { int[] currentBooks = new int[books.size()]; @@ -75,6 +116,11 @@ class User return currentBooks; } + /** + * User borrows a Book + * @param id id of the Book to tbe borrowed + * @return If the borrowing operation is successful + */ public boolean borrowNewBook(int id) { if (status()) @@ -88,6 +134,11 @@ class User } } + /** + * User returns a Book + * @param id id of the Book to be returned + * @return If the returning operation is successful + */ public boolean returnBook(int id) { for (int i = 0; i < books.size(); i++) diff --git a/src/main/java/libsys/UserFactory.java b/src/main/java/libsys/UserFactory.java index d10e747..c7792ed 100644 --- a/src/main/java/libsys/UserFactory.java +++ b/src/main/java/libsys/UserFactory.java @@ -1,7 +1,7 @@ package libsys; /* * Written by : Bin Hong Lee - * Last edited : 5/30/2017 + * Last edited : 6/4/2017 */ import java.util.List; @@ -16,17 +16,25 @@ import java.io.File; import java.util.Enumeration; import java.io.Serializable; -class UserFactory +public class UserFactory { private List users = new ArrayList(); private int id; private String userFilename; + /** + * Create a new empty UserFactory + */ public UserFactory() { id = 0; + userFilename = "users,json"; } + /** + * Create a new UserFactory and fill it with information from a JSON file + * @param userFilename Name of the input JSON file + */ public UserFactory(String userFilename) { try @@ -52,16 +60,20 @@ class UserFactory users.add(new User(name, id, limit, books)); } in.close(); + id = getUser(users.size()-1).getId() + 1; } catch (Exception ex) { System.out.println("Exception importing from json: " + ex.getMessage()); + id = 0; } this.userFilename = userFilename; - id = getUser(users.size()-1).getId() + 1; } + /** + * Output the data into a JSON file replacing the input file (or if filename not given, "users.json") + */ public void toJsonFile() { try @@ -87,11 +99,21 @@ class UserFactory } } + /** + * Update the output filename for the object + * @param userFilename The new filename + */ public void setUserFileName(String userFilename) { this.userFilename = userFilename; } + /** + * Adds a new User into this class + * @param name Name of the User + * @param limit Limit of Book the User can borrow + * @return The new User that is just created + */ public User newUser(String name, int limit) { User temp = new User(name, id, limit); @@ -103,6 +125,11 @@ class UserFactory return temp; } + /** + * Looks for the User with the given name + * @param name Name of the User to be found + * @return User with the given name + */ public User getUser(String name) { for (int i = 0; i < users.size(); i++) @@ -118,21 +145,56 @@ class UserFactory throw new NullPointerException(); } + /** + * Looks for a User with the given id + * @param index id of the User to be found + * @return User with the given id + */ public User getUser(int index) { - for (int i = 0; i < users.size(); i++) + return search(index, 0, users.size() - 1); + } + + /** + * Recursive binary search through the array list for the User with the given id + * @param index id of the User to be found + * @param start Starting point to search + * @param end Ending point to search + * @return User with the given id + */ + private User search(int index, int start, int end) + { + if (start == end && users.get(start).getId() == index) { - User temp = users.get(i); + return users.get(start); + } - if(temp.getId() == index) - { - return temp; - } + if (start >= end) + { + throw new NullPointerException(); } - throw new NullPointerException(); + int currentId = ((start + end) / 2); + + if (users.get(currentId).getId() == index) + { + return users.get(currentId); + } + else if (users.get(currentId).getId() > index) + { + return search(index, start, currentId - 1); + } + else + { + return search(index, currentId + 1, end); + } } + /** + * Replacing a User in the array list with a new User + * @param oldUser User to be replaced + * @param newUser User replacing it + */ public void update(User oldUser, User newUser) { for (int i = 0; i < users.size(); i++)