CSE 1020 - Sample labtest

The class Library represents a library. A library contains a collection of books. A book is represented by the abstract class Book. We only consider two types of books: novels and picture books. These are represented by the classes Novel and PictureBook. All these classes are part of the package labtest4for1020. For more details of these classes, see the API. To work from home, download this jar file and place it in the same folder as type.jar.

Phase 1

First, create a randomly generated Library object. Next, print a text-based representation of the books in the created library. Hint: see API of Library.

Here is a sample run:

Fox, written by Margaret Wild and illustrated by Ron Brooks
To Market, To Market, written by Anne Miranda and illustrated by Janet Stevens
First Day, written by Margaret Wild and illustrated by Kim Gamble
Between You and Me, written by Mike Wallace
The Year of Magical Thinking, written by Joan Didion
A Man without a Country, written by Kurt Vonnegut
Baby Boomsticks, written by Margaret Wild and illustrated by David Legge
The Bilbies of Bliss, written by Margaret Wild and illustrated by Noela Young
The Tender Bar, written by J. R. Moehringer
Here is another sample run:
labtest4for1020.CreationException: Creation failed: creation of picture book failed
In this second sample run, the creation of the library failed. Hint: see API of Library.

Phase 2

Next, expand your program so that it traverses the created library and counts the number of novels and picture books in the library. Print these as shown below.

Here is a sample run:

Fox, written by Margaret Wild and illustrated by Ron Brooks
To Market, To Market, written by Anne Miranda and illustrated by Janet Stevens
First Day, written by Margaret Wild and illustrated by Kim Gamble
Between You and Me, written by Mike Wallace
The Year of Magical Thinking, written by Joan Didion
A Man without a Country, written by Kurt Vonnegut
Baby Boomsticks, written by Margaret Wild and illustrated by David Legge
The Bilbies of Bliss, written by Margaret Wild and illustrated by Noela Young
The Tender Bar, written by J. R. Moehringer
This library contains 4 novels and 5 picture books
Here is another sample run:
labtest4for1020.CreationException: Creation failed: creation of picture book failed

Phase 3

Next, expand your program so that for each picture book, the illustrator is printed on a separate line. Hint: see API of PictureBook.

Here is a sample run:

Fox, written by Margaret Wild and illustrated by Ron Brooks
To Market, To Market, written by Anne Miranda and illustrated by Janet Stevens
First Day, written by Margaret Wild and illustrated by Kim Gamble
Between You and Me, written by Mike Wallace
The Year of Magical Thinking, written by Joan Didion
A Man without a Country, written by Kurt Vonnegut
Baby Boomsticks, written by Margaret Wild and illustrated by David Legge
The Bilbies of Bliss, written by Margaret Wild and illustrated by Noela Young
The Tender Bar, written by J. R. Moehringer
This library contains 4 novels and 5 picture books
Ron Brooks
Janet Stevens
Kim Gamble
David Legge
Noela Young
Here is another sample run:
labtest4for1020.CreationException: Creation failed: creation of picture book failed

Phase 4

Finally, modify the part where the random library is generated. Change your program in such a way that if the creation fails, another attempt is made. More precisely, keep attempting to create a random library until the creation succeeds.

Here is a sample run:

Fox, written by Margaret Wild and illustrated by Ron Brooks
To Market, To Market, written by Anne Miranda and illustrated by Janet Stevens
First Day, written by Margaret Wild and illustrated by Kim Gamble
Between You and Me, written by Mike Wallace
The Year of Magical Thinking, written by Joan Didion
A Man without a Country, written by Kurt Vonnegut
Baby Boomsticks, written by Margaret Wild and illustrated by David Legge
The Bilbies of Bliss, written by Margaret Wild and illustrated by Noela Young
The Tender Bar, written by J. R. Moehringer
This library contains 4 novels and 5 picture books
Ron Brooks
Janet Stevens
Kim Gamble
David Legge
Noela Young