Professional Documents
Culture Documents
In this lab, you continue using Eclipse or NetBean to develop a simple program for managing books in small
library. This program is console-application.
+ UML diagram for Book class: (note “-”: private and “+”: public)
1
+ Add getter/setter methods for private variables
+ Method overloading allows different methods to have same name but different signatures where
signature can differ by number of input parameters or type of input parametere or both. Overloading
constructor of Book class:
- A constructor with no parameter, setting default values for book object’s attributes
- A constructor with full parameters.
+ Write method showBookInfo() to display book’s information in console, formatting the outline as
below:
Book Title: …
Book ID: …
Total Amount: …
Available: …
4. Create Library class
+ UML diagram for Library class: (note “-”: private and “+”: public, underlining: static variable or
static method, constant: CAPITALIZATION)
+ This class maintains an array of book objects, illustration of books in the library.
+ Add a variable named "libraryTitle" to store the title of library.
+ We suppose that, small library only contains a limited number of books. That means: if the current
number of books is over this limited number, users cannot add new book in library.
- Create a class variable named "nbBooks" current number of books in library, each time an
instance of the Book class is added to the library, the nbBooks should be updated.
- Create a constant for limited number of books in library.
2
- Add getter/setter methods for private variables
+ Write constructors for Library class.
+ Method addNewBook(): Add new book
Before creating a new Book object, you should check if the current number of books is below the
MAX_NUMBER_BOOKS.
+ Method findBook(bookID)
Available:
Retuns true, Print out Title, number of books left
Otherwise:
Return false
+ Method borrowBook(bookID)
Check if the book is available or not
If available then borrow, and update the number of books left
Show again the updated status
+ Method returnBook(bookID)
Update the number books left
Show again the updated status
3
+ Write method showLibraryInfo() to display library’s information in console
5. Create Program class
+ UML diagram for Program class: (note “-”: private and “+”: public)