i need help with my homework which is about writing object-oriented code
i have to design a simple library system , i have to write 3 classes
Book class, catalogue class and library class which is a driver class
Book class contain 1 method printdetail()This method summarizes (returns but does notprint) the title, author, ISBN number and year
published in a reader friendly manner.
catalogue class contain 3 methods
1-addBook() Adds new books to the catalogue array; you can
hardcode these books, in other words you don’t have to ask for a user input
2- getBook() Retrieves a book in the catalogue given its index
(index of array)
3- printCatalogue() It calls the printDetails() method to print the details
on the console
library classcontain 2 methods
1-fillData() This method must be present inside the driver class
and should be called by the main method. This
method:
1. Creates a catalogue using the addBook()
method
2. Prints the details of the book using the
printCatalogue() method
2- searchBook() This method must ask the user for input on the
command line. The user enters a book author and
the method searches for the books in the Book
array. If there are no matching books, a message is
displayed stating that no matching books have
been found and the user is asked again to enter an
author. Any matching books, if found, are listed
with all its details. You may want to make use of
the printDetails() method to prepare for printing
these details.
________________________________
i did all the methods except SearchBook()i did not know how to do it
public Book SearchBook(String input){
Scanner reader=new Scanner(System.in);
Book books=new Book();
for(int i=0; i< books.size(); i++) {
Book book=books.get(i);
if(book.getAuthor().equals(input))
{
return book;
}
else
return null; //Book not in library
}
can you help me please
Thanks

New Topic/Question
Reply




MultiQuote








|