Question
For Java While writing your answer to question 1 make use of BookMain to test your solutions to the various parts of the question. This
For Java
While writing your answer to question 1 make use of BookMain to test your solutions to the various parts of the question. This class wont be marked. You will also use the Book and BookCollection classes in this question. 1. Complete the Book class. It should have the following private properties. You class should include a constructor with arguments for each of these properties. Also create getters and setters for each property title (string) author (String) ISBN (long) pages (int) copiesAvailable (int) copiesOnLoan (int) [2 marks] 2. Complete the BookCollection constructor so that it loads the file path argument as a File. Then use a Scanner to read in the file and populate the books arrayList. When complete books should have 100 items in it. Hint: You will need to skip over the first line of the file (the column headers), otherwise you will get an error. [6 marks] 3. Complete the function getAuthors so that it returns a HashSet of all the authors in books. [5 marks] 4. Complete the function getLongBooks so it returns an ArrayList of Books which have over 750 pages in them [5 marks] 5. Complete the function getBookByTitle so it returns the Book object for the given title. If a title not in the list is given return null. [5 marks] 6. Complete the function getMostPopularBooks which returns an array of the 10 most popular books (That is those that currently have most copies on loan). [7 marks] ------------------------------------------------------------------------------------------------------------------------------------
public class Book {
private String title;
private String author;
private long isbn;
private int pages;
private int copiesInCollection;
private int CopiesOnLoan;
//1, complete this class with a constructor that has arguments for all the properties
//and, getters and setters for each of them
}
------------------------------------------------------------------------------------------------------------------------------------
import java.io.File;
import java.io.FileNotFoundException;
import java.util.HashSet;
import java.util.Scanner;
import java.util.ArrayList;
public class BookCollection {
private ArrayList
//2, complete constructor that takes a string path (the BookList file name) load the books from BookList into the books arrayList
//When complete books should have 100 items. Make sure you don't include the header row!
BookCollection(String path) {
}
//3, Return a HashSet of all the authors in the book list
public HashSet
}
//4, return an arrayList of books with more than 750 pages
public ArrayList
}
//5, return the book if the given title is in the list.
public Book getBookByTitle(String title){
}
//6, return an array of the 10 most popular books (That is those that currently have most copies on loan)
public Book[] mostPopular(){
}
}
------------------------------------------------------------------------------------------------------------------------------------
public class BookMain {
public static void main(String[] args) {
BookCollection bCollection = new BookCollection("BookList.csv");
}
} ------------------------------------------------------------------------------------------------------------------------------------ BookList.csv
Title, Author, ISBN, Pages, Copies in collection, Copies on Loan Pride and Prejudice, Jane Austen, 1667248225, 264,6,6 Frankenstein; Or The Modern Prometheus, Mary Wollstonecraft Shelley, 8506864222,901,9, 0 A Christmas Carol in Prose; Being a Ghost Story of Christmas, Charles Dickens, 5481763665,828,12,9 The Adventures of Sherlock Holmes, Arthur Conan Doyle, 3220734336,691,1,0 Alice's Adventures in Wonderland, Lewis Carroll, 6351409589,983,6,0 The Eyes Have It,Philip K. Dick, 9198070332,622,9,8 Moby Dick; Or The Whale, Herman Melville, 4301416227,638,1,0 The Scarlet Letter, Nathaniel Hawthorne, 3509776920, 765, 7,4 A Tale of Two Cities, Charles Dickens, 4884899106,808,12,1 The Great Gatsby, F. Scott Fitzgerald, 3497015912, 267,7, 2 The Picture of Dorian Gray,0scar Wilde, 9176467323,222,10,9 A Modest Proposal, Jonathan Swift, 6433306462,1061,1,1 Dracula, Bram Stoker, 2369773772, 494, 5, 0 A Doll's House : a play, Henrik Ibsen, 9253420026,733,5,3 Great Expectations, Charles Dickens, 3717646794, 351,2,1 The Prince, Niccol Machiavelli, 2692259819,409,9,5 The Importance of Being Earnest: A Trivial Comedy for Serious People,0scar Wilde, 9745993552,406,8,0 Crime and Punishment, Fyodor Dostoyevsky, 7447137770, 795,1, 1 Jane Eyre: An Autobiography, Charlotte Bront, 9297757002,508,9,7 The Strange Case of Dr. Jekyll and Mr. Hyde, Robert Louis Stevenson, 7767403737, 792,9,9 Grimms' Fairy Tales, Jacob Grimm and Wilhelm Grimm, 1172871385,1029,6, 4 Metamorphosis, Franz Kafka, 8832312837,1078, 5, 5 Heart of Darkness, Joseph Conrad, 7878328912, 936,4, The Yellow Wallpaper, Charlotte Perkins Gilman, 3661315070, 419,9,3 Ulysses, James Joyce, 9997506785,517,10,6 Adventures of Huckleberry Finn, Mark Twain, 8065484118, 537, 8, 2 Tractatus Logico-Philosophicus, Ludwig Wittgenstein, 6326453868,1054, 4, 1 The Iliad , Homer, 7847963957,406,12,0 Little Women, Louisa May Alcott,1403156935, 297,8,4 Walden and On The Duty of Civil Disobedience, Henry David Thoreau, 7517871861, 275, 11, 3 The Brothers Karamazov, Fyodor Dostoyevsky, 3229291909, 415, 10, 3 War and Peace, graf Leo Tolstoy,1587765918,492,9,1 The Count of Monte Cristo Illustrated, Alexandre Dumas, 8426279772,767,12,10 Around the World in Eighty Days, Jules Verne, 9136190786,262,3,0 Simple Sabotage Field Manual, United States. Office of Strategic Services, 1175330916,831,11,7 The Adventures of Tom Sawyer Complete,Mark Twain, 7792130736,615,3,1 Don Quixote, Miguel de Cervantes Saavedra, 4287982712,849,6,1 Twas the Night before Christmas: A Visit from St. Nicholas, Clement Clarke Moore, 8906769756, 282,1, 1 Anne of Green Gables, L. M. Montgomery, 3790819962, 527,12, 3 Anna Karenina,graf Leo Tolstoy,6572493746,1064,4,4 The Romance of Lust: A classic Victorian erotic novel, Anonymous, 7462179668,372,4,3 Treasure Island, Robert Louis Stevenson, 2137266088, 580, 11, 6 The Prophet, Kahlil Gibran,1947108195, 632,2, 2 The Republic,Plato, 3659035355, 298, 2,0 Wuthering Heights, Emily Bront, 3553479206, 783, 2, The Wonderful Wizard of Oz, L. Frank Baum, 7357027396,858,2,1Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started