Question: COMP2501 Lab 3 Create a Novel class with private instance variables, constructor parameters, and accessor methods for title, author name, and year published Create

COMP2501 Lab 3 Create a Novel class with private instance variables, constructorparameters, and accessor methods for "title", "author name", and "year published" Createa BookStore class that contains an instance variable for the BookStore's name(e.g. "Books-R- Us"). The BookStore constructor will not accept a name of"Amazon" (in any letter casing), however; if the name is "Amazon", changeit to Chapters" instead. The BookStore contains a second instance variable thatis an ArrayList of 109 Novel references. Due the night before nextclass Create a Lab3 class which implements the main(...) method and populatesthe BookStore ArrayList using the following code: store.addNovel(new Novel("The Adventures of AugieMarch", "Saul Bellow", 1953)); store.addNovel(new Novel("All the Kings Men", "Robert Penn Warren",1946)); store.addNovel(new Novel("American Pastoral", "Philip Roth", 1997)); store.addNovel(new Novel("An American Tragedy", "Theodore

COMP2501 Lab 3 Create a Novel class with private instance variables, constructor parameters, and accessor methods for "title", "author name", and "year published" Create a BookStore class that contains an instance variable for the BookStore's name (e.g. "Books-R- Us"). The BookStore constructor will not accept a name of "Amazon" (in any letter casing), however; if the name is "Amazon", change it to Chapters" instead. The BookStore contains a second instance variable that is an ArrayList of 109 Novel references. Due the night before next class Create a Lab3 class which implements the main(...) method and populates the BookStore ArrayList using the following code: store.addNovel(new Novel("The Adventures of Augie March", "Saul Bellow", 1953)); store.addNovel(new Novel("All the Kings Men", "Robert Penn Warren", 1946)); store.addNovel(new Novel("American Pastoral", "Philip Roth", 1997)); store.addNovel(new Novel("An American Tragedy", "Theodore Dreiser", 1925)); store.addNovel(new Novel("Animal Farm", "George Orwell", 1946)); store.addNovel(new Novel("Appointment in Samarra", "John O'Hara", 1934)); store.addNovel(new Novel(null, null, 1)); store.addNovel(new Novel(null, "author name 1", 2)); store.addNovel(new Novel("", null, 3)); store.addNovel(new Novel(null, ", 4)); store.addNovel(new Novel("title 1", null, 5)); store.addNovel(new Novel("", ""', 6)); store.addNovel(new Novel("", "author name 2", 7)); store.addNovel(new Novel("title", 9 8)); store.addNovel(new Novel("Are You There God? It's Me, Margaret.", "Judy Blume", 1970)); store.addNovel(new Novel("The Assistant", "Bernard Malamud", 1957)); store.addNovel(new Novel("At Swim-Two-Birds", "Flann O'Brien", 1938)); store.addNovel(new Novel("Atonement", "Ian McEwan", 2002)); store.addNovel(new Novel("Beloved", "Toni Morrison", 1987)); store.addNovel(new Novel("The Berlin Stories", "Christopher Isherwood", 1946)); store.addNovel(new Novel("The Big Sleep", "Raymond Chandler", 1939)); store.addNovel(new Novel("The Blind Assassin", "Margaret Atwood", 2000)); store.addNovel(new Novel("Blood Meridian", "Cormac McCarthy", 1986)); 11 store.addNovel(new Novel("Brideshead Revisited", "Evelyn Waugh", 1946)); store.addNovel(new Novel("The Bridge of San Luis Rey", "Thornton Wilder", 1927)); store.addNovel(new Novel("Call It Sleep", "Henry Roth", 1935)); store.addNovel(new Novel("Catch-22", "Joseph Heller", 1961)); store.addNovel(new Novel("The Catcher in the Rye", "J.D. Salinger", 1951)); store.addNovel(new Novel("A Clockwork Orange", "Anthony Burgess", 1963)); store.addNovel(new Novel("The Confessions of Nat Turner", "William Styron", 1967)); store.addNovel(new Novel("The Corrections", "Jonathan Franzen", 2001)); store.addNovel(new Novel("The Crying of Lot 49", "Thomas Pynchon", 1966)); store.addNovel(new Novel("A Dance to the Music of Time", "Anthony Powell", 1951)); store.addNovel(new Novel("The Day of the Locust", "Nathanael West", 1939)); store.addNovel(new Novel("Death Comes for the Archbishop", "Willa Cather", 1927)); store.addNovel(new Novel("A Death in the Family", "James Agee", 1958)); store.addNovel(new Novel("The Death of the Heart", "Elizabeth Bowen", 1958)); COMP2501 1 Lab 3 } Due the night before next class store.addNovel(new Novel("Deliverance", "James Dickey", 1970)); store.addNovel(new Novel("Dog Soldiers", "Robert Stone", 1974)); store.addNovel(new Novel("Falconer", "John Cheever", 1977)); store.addNovel(new Novel("The French Lieutenant's Woman", "John Fowles", 1969)); store.addNovel(new Novel("The Golden Notebook", "Doris Lessing", 1962)); store.addNovel(new Novel("Go Tell It on the Mountain", "James Baldwin", 1953)); store.addNovel(new Novel("Gone with the Wind", "Margaret Mitchell", 1936)); store.addNovel(new Novel("The Grapes of Wrath", "John Steinbeck", 1939)); store.addNovel(new Novel("Gravity's Rainbow", "Thomas Pynchon", 1973)); store.addNovel(new Novel("The Great Gatsby", "F. Scott Fitzgerald", 1925)); store.addNovel(new Novel("A Handful of Dust", "Evelyn Waugh", 1934)); store.addNovel(new Novel("The Heart Is a Lonely Hunter", "Carson McCullers", 1940)); store.addNovel(new Novel("The Heart of the Matter", "Graham Greene", 1948)); store.addNovel(new Novel("Herzog", "Saul Bellow", 1964)); store.addNovel(new Novel("Housekeeping", "Marilynne Robinson", 1981)); store.addNovel(new Novel("A House for Mr. Biswas", "V.S. Naipaul", 1962)); store.addNovel(new Novel("I, Claudius", "Robert Graves", 1934)); store.addNovel(new Novel("Infinite Jest", "David Foster Wallace", 1996)); store.addNovel(new Novel("Invisible Man", "Ralph Ellison", 1952)); store.addNovel(new Novel("Light in August", "William Faulkner", 1932)); store.addNovel(new Novel("The Lion, The Witch and the Wardrobe", "C.S. Lewis", 1950)); store.addNovel(new Novel("Lolita", "Vladimir Nabokov", 1955)); store.addNovel(new Novel("Lord of the Flies", "William Golding", 1954)); store.addNovel(new Novel("The Lord of the Rings", "J.R.R. Tolkien", 1954)); store.addNovel(new Novel("Loving", "Henry Green", 1945)); store.addNovel(new Novel("Lucky Jim", "Kingsley Amis", 1954)); store.addNovel(new Novel("The Man Who Loved Children", "Christina Stead", 1940)); store.addNovel(new Novel("Midnight's Children", "Salman Rushdie", 1981)); store.addNovel(new Novel("Money", "Martin Amis", 1984)); store.addNovel(new Novel("The Moviegoer", "Walker Percy", 1961)); store.addNovel(new Novel("Mrs. Dalloway", "Virginia Woolf", 1925)); store.addNovel(new Novel("Naked Lunch", "William Burroughs", 1959)); store.addNovel(new Novel("Native Son", "Richard Wright", 1940)); store.addNovel(new Novel("Neuromancer", "William Gibson", 1984)); store.addNovel(new Novel("Never Let Me Go", "Kazuo Ishiguro", 2005)); store.addNovel(new Novel("1984", "George Orwell", 1948)); store.addNovel(new Novel("On the Road", "Jack Kerouac", 1957)); store.addNovel(new Novel("One Flew Over the Cuckoo's Nest", "Ken Kesey", 1962)); store.addNovel(new Novel("The Painted Bird", "Jerzy Kosinski", 1965)); store.addNovel(new Novel("Pale Fire", "Vladimir Nabokov", 1962)); store.addNovel(new Novel("A Passage to India", "E.M. Forster", 1924)); store.addNovel(new Novel("Play It as It Lays", "Joan Didion", 1970)); store.addNovel(new Novel("Portnoy's Complaint", "Philip Roth", 1969)); store.addNovel(new Novel("Possession", "A.S. Byatt", 1990)); store.addNovel(new Novel("The Power and the Glory", "Graham Greene", 1939)); store.addNovel(new Novel("The Prime of Miss Jean Brodie", "Muriel Spark", 1961)); store.addNovel(new Novel("Rabbit, Run", "John Updike", 1960)); store.addNovel(new Novel("Ragtime", "E.L. Doctorow", 1975)); { 2 COMP2501 Lab 3 store.addNovel(new Novel("The Recognitions", "William Gaddis", 1955)); store.addNovel(new Novel("Red Harvest", "Dashiell Hammett", 1929)); store.addNovel(new Novel("Revolutionary Road", "Richard Yates", 1961)); store.addNovel(new Novel("The Sheltering Sky", "Paul Bowles", 1949)); store.addNovel(new Novel("Slaughterhouse-Five", "Kurt Vonnegut", 1969)); store.addNovel(new Novel("Snow Crash", "Neal Stephenson", 1992)); store.addNovel(new Novel("The Sot-Weed Factor", "John Barth", 1960)); store.addNovel(new Novel("The Sound and the Fury", "William Faulkner", 1929)); store.addNovel(new Novel("The Sportswriter", "Richard Ford", 1986)); store.addNovel(new Novel("The Spy Who Came in from the Cold", "John le Carre", 1964)); store.addNovel(new Novel("The Sun Also Rises", "Ernest Hemingway", 1926)); store.addNovel(new Novel("Their Eyes Were Watching God", "Zora Neale Hurston", 1937)); store.addNovel(new Novel("Things Fall Apart", "Chinua Achebe", 1959)); store.addNovel(new Novel("To Kill a Mockingbird", "Harper Lee", 1960)); store.addNovel(new Novel("To the Lighthouse", "Virginia Woolf", 1929)); store.addNovel(new Novel("Tropic of Cancer", "Henry Miller", 1934)); store.addNovel(new Novel("Ubik", "Philip K. Dick", 1969)); store.addNovel(new Novel("Under the Net", "Iris Murdoch", 1954)); store.addNovel(new Novel("Under the Volcano", "Malcolm Lowry", 1947)); store.addNovel(new Novel("Watchmen", "Alan Moore and Dave Gibbons", 1986)); store.addNovel(new Novel("White Noise", "Don DeLillo", 1985)); store.addNovel(new Novel("White Teeth", "Zadie Smith", 2000)); store.addNovel(new Novel("Wide Sargasso Sea", "Jean Rhys", 1966)); Due the night before next class The main method also a commandline arguments, which will be the name of the BookStore; store the commandline argument as the name of the BookStore (unless it is "Amazon"...see above). Here is a snapshot of some of the code: print All Titles Create the following BookStore methods. Do proper null and blank checking so that no crashes occur and no empty/blank strings appear: Method name none Parameters Resulting behavior Prints all titles in UPPERCASE Create the following BookStore methods. Do proper null and blank checking so that no crashes occur and no empty/blank strings appear: Method name printAll Titles print TitlesContaining print TitlesOfLength COMP2501 printNameStartsEndsWith getLongest Parameters none String substring boolean caseSensitive int length (2) Lab 3 String substring String property Resulting behavior Prints all titles in UPPERCASE Prints all titles that contain the specified substring; if caseSensitive is false, then the match is in any letter casing (e.g. "The" is the same as "the"); if caseSensitive is true then the match must include letter casing (e.g. "The" is different than "the") Prints all titles that are of exactly the specified length Due the night before next class Prints all author names that either start or end with substring, in lowercase...the substring match is case insensitive (e.g. "aN" is the same as "An", etc) If the property argument is "author" (in any letter casing) then return the longest author name (by finding it using a foreach loon) if the property getLongest main String property printAllTitles String[] args Sample correct output when the BookStore's methods are called from Lab3.main(...): BookStore method name AN AMERICAN TRAGEDY ANIMAL FARM Same as Al etc) If the property argument is "author" (in any letter casing) then return the longest author name (by finding it using a foreach loop); if the property argument is "title" (in any letter casing) then return the longest title (by finding it using a foreach loop); if the property argument is something else then return null ATONEMENT BELOVED THE ADVENTURES OF AUGIE MARCH ALL THE KING'S MEN AMERICAN PASTORAL THE BERLIN STORIES THE BIG SLEEP THE BLIND ASSASSIN BLOOD MERIDIAN Creates BookStore object and passes args[0] to BookStore constructor as its name property Calls all of the BookStore methods listed above, in this table APPOINTMENT IN SAMARRA TITLE 1 TITLE ARE YOU THERE GOD? IT'S ME, MARGARET. THE ASSISTANT AT SWIM-TWO-BIRDS BRIDESHEAD REVISITED THE BRIDGE OF SAN LUIS REY CALL IT SLEEP CATCH-22 Expected Output 9 THE CATCHER IN THE RYE A CLOCKWORK ORANGE THE CONFESSIONS OF NAT TURNER THE CORRECTIONS THE CRYING OF LOT 49 A DANCE TO THE MUSIC OF TIME b.printAllTitlesContaining("the", false); COMP2501 Lab 3 THE POWER AND THE GLORY THE PRIME OF MISS JEAN BRODIE RABBIT, RUN RAGTIME THE RECOGNITIONS RED HARVEST REVOLUTIONARY ROAD THE SHELTERING SKY SLAUGHTERHOUSE-FIVE SNOW CRASH THE SOT-WEED FACTOR THE SOUND AND THE FURY THE SPORTSWRITER THE SPY WHO CAME IN FROM THE COLD THE SUN ALSO RISES THEIR EYES WERE WATCHING GOD THINGS FALL APART TO KILL A MOCKINGBIRD TO THE LIGHTHOUSE TROPIC OF CANCER UBIK UNDER THE NET UNDER THE VOLCANO WATCHMEN WHITE NOISE WHITE TEETH WIDE SARGASSO SEA The Adventures of Augie March All the King's Men Are You There God? It's Me, Margaret. The Assistant The Berlin Stories The Big Sleep The Blind Assassin The Bridge of San Luis Rey The Catcher in the Rye The Confessions of Nat Turner The Corrections The Crying of Lot 49 A Dance to the Music of Time The Day of the Locust Death Comes for the Archbishop A Death in the Family The Death of the Heart The French Lieutenant's Woman The Golden Notebook Go Tell It on the Mountain Gone with the Wind The Grapes of Wrath Due the night before next class COMP2501 b.printAllTitlesContaining("the", true); b.printAllTitles (13); printNameStartsEndsWith("aN") System.out.println(b.getLongest("xyz")); System.out.println(b.getLongest("AutHor")); System.out.println(b.getLongest("titlE")); Lab 3 The Golden Notebook Go Tell It on the Mountain Gone with the Wind The Grapes of Wrath The Great Gatsby The Heart Is a Lonely Hunter The Heart of the Matter The Lion, The Witch and the Wardrobe Lord of the Flies The Lord of the Rings The Man Who Loved Children The Moviegoer On the Road One Flew Over the Cuckoo's Nest The Painted Bird The Power and the Glory The Prime of Miss Jean Brodie The Recognitions The Sheltering Sky The Sot-Weed Factor The Sound and the Fury The Sportswriter The Spy Who Came in from the Cold The Sun Also Rises Their Eyes Were Watching God To the Lighthouse Under the Net Under the Volcano All the King's Men The Catcher in the Rye A Dance to the Music of Time The Day of the Locust Death Comes for the Archbishop A Death in the Family The Death of the Heart Due the night before next class Go Tell It on the Mountain Gone with the Wind The Heart of the Matter The Lion, The Witch and the Wardrobe Lord of the Flies The Lord of the Rings On the Road One Flew Over the Cuckoo's Nest The Power and the Glory The Sound and the Fury The Spy Who Came in from the Cold To the Lighthouse Under the Net Under the Volcano The Assistant The Big Sleep Call It Sleep Infinite Jest Invisible Man The Moviegoer Mrs. Dalloway Under the Net ianmcewan anthony burgess anthonypowell null Alan Moore and Dave Gibbons Are You There God? It's Me, Margaret. Work on this lab with a new partner: someone with whom you have not yet worked. Write the code for the lab below and each partner must upload the zipped src folder to the learning hub (learn.bcit.ca Activities Assignments Lab4) before the start of lesson 5. Include your full name and your partner's full name at the top of each file, using a Java Javadoc /** @author */ tag (for example: /** @author Bullwinkle Moose */). Re-do lab 3 but this time the following methods must throw the following Exceptions given the following conditions: Make sure your methods declare the Exceptions they throw (and Javadoc @throws too). For example: /** * @param parameter - some parameter @throws IllegalArgumentException if parameter is bigger than 100, or is null */ public void pretendMethod (String parameter) throws IllegalArgumentException { } // code goes here printTitlesOfLength(int length) Must throw an IllegalArgumentException if length is O or negative with the message "bad length" printTitlesOfLength(int length) Must throw an IllegalArgumentException if length is O or negative with the message "bad length" printNameStartsEndsWith(String substring) Must throw a checked Exception (YOU create the class) named IllegalNameException with the message "bad name" if the substring parameter is null or blank COMP2501 try { } { // code to try 1 printTitlesContaining (String substring, boolean caseSensitive) Must throw an IllegalArgumentException (with message bad string") if the substring parameter is blank or null catch(Exception TypeOne e) Lab 4 NOTE: when a method or constructor throws one of several different methods, the try/catch block is extended as follows: } Due before next class 2 of 2 COMP2501 try { } printTitlesContaining (String substring, boolean caseSensitive) Must throw an IllegalArgumentException (with message "bad string") if the substring parameter is blank or null NOTE: when a method or constructor throws one of several different methods, the try/catch block is extended as follows: catch(ExceptionTypeOne e) { } // code to try { catch(ExceptionTypeTwo e) } Etc... // handle exception type one here Automatic Zoom Lab 4 // handle exception type two here View as lext Download Due before next class getLongest(String property) Must throw an unchecked Exception (YOU create the class) named Illegal Novel PropertyException with the message "bad property" if its value is not "author" nor "title" (in any letter casing) main(String[] args) Must try/catch all of its methods now; in the event of an Exception being thrown, simply print the Exception object's getMessage() method output.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!