Question: Implement the following UML diagram: Write an interface Searchable that has an abstract method: boolean hasKeyword(String keyword) Write a class Document (described in the above
Implement the following UML diagram:

Write an interface Searchable that has an abstract method:
boolean hasKeyword(String keyword)
Write a class Document (described in the above UML diagram) that implements the interface
Searchable. Note that:
The first document created will have the number 1, the second one created will have the number 2, and so on.
The data field author is an array of type String.
Implement the method hasKeyword that returns true if the title contains the given keyword.
Write the two sub-classes Book and Dictionary (described in the above UML diagram) that inherit the class Document.
Write a class MyFile (described in the above UML diagram) that implements the interface Searchable. The goal of this class is to create a file which points to a text file on the disk. This file will be used to save the titles of documents. The class MyFile contains:
A data field file of type File
A constructor that receives a file name and creates a file
A method add(String title) that adds received title of a document to the file
Implement the method hasKeyword
Note: You are requested to use the appropriate exception, as well the finally block
Write a class DocumentList that represents a list which contains objects of the class Document
as well as an object of the class MyFile. The DocumentList contains:
An array of type Document
A data field myFile of type MyFile
A default constructor that declares an array, and creates an object of MyFile
A method addDocument(Document d)that adds d to the array
A method allAuthors() that displays all the authors
A method allDocuments()that displays all the documents
A method addToFile(Document d) that adds the title of d to the file
A method search(String Keyword) that searches Keyword in the array of documents
A method searchInFile(String Keyword) that searches Keyword in the file
Finally, write an application Library that:
Create 3 books and 2 dictionaries, add them to the array of documents and to the file
Display all authors as well all documents
Ask the user to enter a title, and then search the title in both the list of documents and the file. Display the results.
Note: Throw an exception while the user enters an empty title.
Write an interface Searchable that has an abstract method:
boolean hasKeyword(String keyword)
Write a class Document (described in the above UML diagram) that implements the interface
Searchable. Note that:
The first document created will have the number 1, the second one created will have the number 2, and so on.
The data field author is an array of type String.
Implement the method hasKeyword that returns true if the title contains the given keyword.
Write the two sub-classes Book and Dictionary (described in the above UML diagram) that inherit the class Document.
Write a class MyFile (described in the above UML diagram) that implements the interface Searchable. The goal of this class is to create a file which points to a text file on the disk. This file will be used to save the titles of documents. The class MyFile contains:
A data field file of type File
A constructor that receives a file name and creates a file
A method add(String title) that adds received title of a document to the file
Implement the method hasKeyword
Note: You are requested to use the appropriate exception, as well the finally block
Write a class DocumentList that represents a list which contains objects of the class Document
as well as an object of the class MyFile. The DocumentList contains:
An array of type Document
A data field myFile of type MyFile
A default constructor that declares an array, and creates an object of MyFile
A method addDocument(Document d)that adds d to the array
A method allAuthors() that displays all the authors
A method allDocuments()that displays all the documents
A method addToFile(Document d) that adds the title of d to the file
A method search(String Keyword) that searches Keyword in the array of documents
A method searchInFile(String Keyword) that searches Keyword in the file
Finally, write an application Library that:
Create 3 books and 2 dictionaries, add them to the array of documents and to the file
Display all authors as well all documents
Ask the user to enter a title, and then search the title in both the list of documents and the file. Display the results.
Note: Throw an exception while the user enters an empty title.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
