Question
Asked by:
nicholsbradley
nicholsbradley
Rating : No Rating
Questions Asked: 21
Tutorials Posted: 0
 

$15.00 Help please 8

Q:
Create a Book class that stores book information. Your book class will store book title, author’s first name, author’s last name, book ISBN-10 number, and publisher, and price. Ensure you have created appropriate constructor(s) that will allow your test application to construct objects of type Book.

You can decide how to obtain the information used for each Book object you create. Each book’s information can be entered through the keyboard, read in from a file, or constructed by using hard coded values in your test application.

Create a test application that creates several objects of type Book class and adds each Book object to an ArrayList. Do not store your book information as a String and add this String into your ArrayList. You should store Book objects that encapsulate your book information and store these in your ArrayList:

//Creates arrayList to store book objects
ArrayList<Book> bookList = new ArrayList<Book>();

Your test application should then do the following:

Iterate through all Books in the ArrayList and print the information out in readable form.
Print the total number of books stored.
Prompt you for an index and print the book information stored in the index.
Hint: You may want to look into overriding toString() method to provide a readable string representation of Book object.

Example output of application:





Before you write any Java code, start with planning comments also known as pseudocode. These comments will serve as the outline of your logic for each method including your test application. The comments should be left in your code and part of your grade will come from these comments
 
Attachments:
Output.docx (154K)


   
   
   
   
 
Available Tutorials to this Question
Posted by:
thementoronline
thementoronline
Rating (97): C-
Questions Asked: 18
Tutorials Posted: 1611, earned $1,313.13
 

$15.00 Best Answers

  • This tutorial hasn't been purchased yet.
  • Posted on Jul. 28, 2009 at 11:23:27AM
A:
Preview: ... give positive feedback (and I will gi ...

The full tutorial is about 31 words long plus attachments.

Attachments:
books.zip (1K)
Posted by:
modulo51
modulo51
Rating (110): A-
Questions Asked: 1
Tutorials Posted: 353, earned $2,117.64
 

$15.00 Java: Book & Demo classes, BufferedReader input, NebBeans folder, UseNotes, ScreenShot

  • This tutorial was purchased 3 times and hasn't been rated yet.
  • Posted on Jul 28, 2009 at 10:58:24PM
A:
Preview: ... (), // ISMB<br> Double.parseDouble(inStream.readLine().trim())); // price<br><br> // this displays each book as it's being read in:<br>// System.out.println(yep.toString());<br><br> bookList.add(yep);<br><br> // tead the empty line separating books in the file:<br> // this black line must follow each block of book into<br> // there must NOT be an empty line at the top of the file!<br> inStream.readLine();<br><br> }<br> } catch (Exception e) {<br> System.out.println(e.toString());<br> return;<br> }<br> }<br><br> public static void displayAllBooks() {<br> listIter = bookList.listIterator(0);<br> System.out.println(<br> "\\n\\tBooks currently in the inventory:\\n");<br> if (bookList.size() == 0) {<br> System.out.println(<br> "There are no books in the inventory!");<br> return;<br> }<br><br> while (listIter.hasNext()) {<br> System.out.println(<br> ((Book) listIter.next()).toString());<br> }<br> }<br><br> public static void printNumBooks() {<br> System.out.println(<br> "\\nThe total number of books stored is: " + bookList.size());<br> }<br><br> public static void bookInfoAtIndex() {<br><br> System.out.print(<br> "Enter index of book: ");<br> try {<br> int index = Integer.parseInt(keyboard.nextLine());<br> index--;<br> if (index < 0 || index > bookList.size() - 1) {<br> System.out.println(<br> "Invalid index, you will be returned to the main menu.");<br> return;<br> }<br> System.out.println(bookList.get(index).toString ...

The full tutorial is about 3136 words long plus attachments.

Attachments:
Book.java (5K) (Preview)
BookInventoryScreenShot.JPG (63K) (Preview)
BookInventoryUseNotes.txt (8K) (Preview)
BookInventoryZipped.zip (137K)
   
Join Now or Log In
Get Tutoring
Get Paid
Academic Honesty