HW4 (2)

pdf

School

New York University *

*We aren’t endorsed by this school

Course

0101

Subject

Computer Science

Date

Jan 9, 2024

Type

pdf

Pages

4

Uploaded by GrandMouseMaster851

Report
CSCI-UA.0101 010 INTRODUCTION TO COMPUTER SCIENCE FALL 2023 HOMEWORK 4 Due date: 11.21.2023 11:59pm Late due: 11.24.2023 11:59pm In this assignment, you will implement a Library Project. Two basic classes of this project are: Library and Book. Details are as follows: Library has a name (String), foundation year (int), number of books (int) and book array (arraylist is allowed) variables where all of them are private. Book has a name (String), publication year (int), number of authors (int) and author list (String list) variables where all of them are private. Book class implements Comparable interface and compares the publication year of books. This will later be used while sorting our books. Both classes have one proper constructor where: o Library sets the name, number of books and foundation year with arguments but sets the book details by calling a method, namely, setLibraryBooks(int numberOfBooks) o Book sets the name, number of authors and the publication year with arguments but sets the author name(s) by calling a method, namely, setMyAuthors(int numberOfAuthors) setMyAuthors(int numberOfAuthors) method mentioned above initializes the size of your authors string array and ask the user to enter the names and inserts them into the String array one by one. setLibraryBooks(int numberOfBooks) mentioned above set the corresponding book list by first initializing the array size and then by asking the user to enter information for each Book. Do not forget that these are Book objects and they need to be handled carefully. Ask related information to the user which matches with requirements of a Book class object. Additionally, you will implement 4 inherited classes: Fiction, NonFiction, ScienceFiction and CrimeFiction. Please see the given UML diagram for details.
-isScientific:Boolean -isAcademic:Boolean -glossary(list:String) +NonFiction(n:String, y:int,nr:int, s:Boolean, a:Boolean) +setGlossary():void NonFiction -name: String -publicationYear:int -nrOfAuthors:int -authors(list:String) +Book(n:String, y:int,nr:int) +setMyAuthors(n:int):void Book -type:String -plot:String +Fiction(n:String, y:int,nr:int, t:String,p:String) +changePlot():void Fiction -timeTravel:Boolean -apocalyptic:Boolean +ScienceFiction(n:String, y:int,nr:int, t:String,p:String, tt:Boolean, ap: Boolean) ScienceFiction -spy:Boolean -suspense:Boolean +ScienceFiction(n:String, y:int,nr:int, t:String,p:String, spy:Boolean, sp: Boolean) CrimeFiction
Please note that constructor of each class takes arguments for its superclass, too, in order to set them. After implementing these classes, write a comprehensive driver class which sets up the library first and books, later. Please enter small number of books even if it is not realistic. We are just testing the system, no need to enter thousands of books! The user should also be able to search the library. Please see one of the sample outputs below. Sample Output 1: Enter the name of the library: Sleepy Hollow City Library Enter the foundation year: 1963 Enter the number of books: 3 Now we start to save information of each book. Book 1 Enter F for fiction and N for non-fiction: F Enter S for science fiction and C for crime fiction: S Enter the name of your book: World War Z Enter the publication year of your book: 2006 Enter the number of authors: 1 Name of Author 1: Max Brooks Enter plot: The novel is a collection of individual accounts narrated by an agent of the United Nations Postwar Commission, following the devastating global conflict against the zombie plague. Other passages record a decade-long desperate struggle, as experienced by people of various nationalities. Is your book related to time travel (Y for yes / N for no): N Is your book related to post- apocalyptic events (Y for yes / N for no): Y Your book is set up. Book 2 Enter F for fiction and N for non-fiction: N Enter the name of your book: The Future We Choose Surviving The Climate Crisis Enter the publication year of your book: 2020 Enter the number of authors: 2 Name of Author 1: Christina Figueres Name of Author 2: Tom Rivett-Carnac Is your book related to science (Y for yes / N for no): Y Is your book related to academia (Y for yes / N for no): N Enter how many terms you have in your glossary: 3 Enter glossary item 1: climate Enter glossary item 2: energy Enter glossary item 3: future Your book is set up.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Book 3 Enter F for fiction and N for non-fiction: N Enter the name of your book: Environmental Issues in the 1990s Enter the publication year of your book: 1992 Enter the number of authors: 2 Name of Author 1: A.M. Mannion Name of Author 2: S.R. Bowlby Is your book related to science (Y for yes / N for no): Y Is your book related to academia (Y for yes / N for no): N Enter how many terms you have in your glossary: 2 Enter glossary item 1: climate Enter glossary item 2: future Your book is set up. The library is set up. Do you want to search for an author ( Y for yes / N for exit): Y Enter the surname of the author: Figueres A match is found! Book: The Future We Choose Surviving The Climate Crisis Type: Non-Fiction Do you want to search for an author ( Y for yes / N for exit): Y Enter the surname of the author: Marshner Sorry, no match is found! Do you want to search for an author ( Y for yes / N for exit): N Thank you for setting up our library system!! After we sort the books by using comparable interface wrt date, their order is: Environmental Issues in the 1990s from 1992 World War Z from 2006 The Future We Choose Surviving The Climate Crisis from 2020