Beruflich Dokumente
Kultur Dokumente
1 Problem Statement
The libraries of SmallTownX need a new electronic rental system, and it is up to
you to build it. SmallTownX has two libraries. Each library offers many books
to rent. Customers can print the list of available books, borrow, and return
books.
There are three classes Book , Author and Library, that provide the func-
tionality for the book database. You must implement the methods to make
these classes work.
Book:
– title: String
– author: String
– borrowed:boolean
– bookNumber: int
Book class Contains Following methods:
1. Add a constructor with all the attributes of the class Book. (Hint: It
should look like Book(Title, borrowed, bookNumber)
2. Add the getter and setter methods for the class Book.(Your methods
should be named properly for example setter and getter method for ti-
tle will be named as setName and getName)
1
3. Add another method called void display() that prints out all the values
of the attributes.
4. Implement these two methods
1 // Marks t h e book a s r e n t e d
2 p u b l i c v o i d borrowed ( ) {
3 // Implement t h i s method
4 }
5 // Marks t h e book a s not r e n t e d
6 public void returned ( ) {
7 // Implement t h i s method
8 }
Listing 1: Implement these methods
2
4 Change class Book.author attribute
Change class Book.author attribute from String to the Author type as: Book:
– title: String
– author: Author
– borrowed:boolean
– bookNumber: int
LIBRARY :
– Books[10]: Book(The Size of Book array is 10)
– libraryHours : String
– address : String
Library class Contains Following methods:
3
2. Add the getter/setters methods for the address and library hours.
3. write a method addbook(Book book) which takes a book as a argument
and add this to books array.
4. write a method printOpeningHours()that prints the library hours.
4
5. Print all books in library one
6. Return two books
8 Submission guidelines
• you had to submit three files
– Book.java
– Author.java
– Library.java
• Each class will have its own main method in which you will perform the
given tests.
• Your files name should be as:
– XXX-BSCS-20XXBook.java
– XXX-BSCS-20XXAuthor.java
– XXX-BSCS-20XXLibrary.java
• At the top of the every file put title in comments as:
IN-LAB 2 : Solution
Your name
your roll no. XXX-BSCS-20XX (Section XX)
• No collaboration/group work is required. Copied assignments will get no
marks.
• Labs Submitted After Deadline or not following submission guidelines will
get No marks.