Question
Asked by:
JavaDummy25
JavaDummy25
Rating : No Rating
Questions Asked: 27
Tutorials Posted: 0
 

$5.00 OOP Program

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
 


   
   
   
   
 
Available Tutorials to this Question
Posted by:
rannok_026
rannok_026
Rating (200): A-
Questions Asked: 5
Tutorials Posted: 1453, earned $4,809.95
 

$5.00 OOP Program

  • This tutorial was purchased 2 times and rated A+ by students like you.
  • Posted on Aug 06, 2009 at 9:16:19PM
A:
Preview: ... attachme ...

The full tutorial is about 5 words long plus attachments.

Attachments:
Book.java (2K) (Preview)
TestApplication.java (2K) (Preview)
Posted by:
 

$5.00 Perfect A+ solution

  • This tutorial hasn't been purchased yet.
  • Posted on Aug 06, 2009 at 10:18:46PM
A:
Preview: ... // passes values to the parameterised constructor<br> <br>booklst.add(b1); // add the object to the array list<br> <br>System.out.print("\\n Do u want to add more books[Y-yes]: ");<br>ch=in.readLine(); // receives decision from user <br> <br>}while(ch.equalsIgnoreCase("y")); // continues if 'y' has been pressed<br> <br> <br> bookno=1; <br> Iterator it=booklst.iterator(); <br> <br> while(it.hasNext()) // continues until there are more objects<br> {<br> book b2=new book(); // object to display information from array list <br> b2=(book)it.next();<br> <br> b2.displayBo ...

The full tutorial is about 320 words long plus attachments.

Attachments:
books.java (3K) (Preview)
RESULT.JPG (31K) (Preview)
Posted by:
modulo51
modulo51
Rating (110): A-
Questions Asked: 1
Tutorials Posted: 353, earned $2,117.64
 

$15.00 Java: BookInventory, ArrayList<Book>, Scanner input, NetBeans folder, StringTokenizer, UseNotes, ScreenShot

  • This tutorial was purchased 1 time and rated A+ by students like you.
  • Posted on Aug 07, 2009 at 10:45:40PM
A:
Preview: ... baloney.setISBN("0446386405");<br> baloney.setPublisher("Warner Books");<br> baloney.setPrice(6.95);<br><br> Book.bookList.add(baloney);<br><br> int choice = 0;<br> do {<br> choice = menu();<br><br> switch (choice) {<br> case 1: // iterate & print info for all books<br> Book.displayAllBooks();<br> break;<br> case 2: // print number of books:<br> Book.printNumBooks();<br> break;<br> case 3: // book info at an index<br> Book.bookInfoAtIndex();<br> break;<br> case 4: // quit<br> break;<br> default:<br> System.out.println(<br> "Not a valid choice, please try again.");<br> }<br> } while (choice != 4);<br><br> }<br><br> static int menu() {<br><br> String line;<br> int choice = 0;<br> while (true) {<br> System.out.println(<br> "\\\\n\\\\tMain Menu\\\\n" +<br> " 1 - Iterate through Book list and print " +<br> "information for each book.");<br> System.out.println(<br> " 2 - Print the total number of books stored.");<br> System.out.println(<br> " 3 - Get book information at an index...");<br> System.out.println(<br> " 4 - Quit program.");<br> System.out.print("Please choose: ");<br> try {<br> line = kb.nextLine();<br> if (line.equals("")) {<br> return 0;<br> }<br> choice =<br> Integer.parseInt(line);<br> if (ch ...

The full tutorial is about 3042 words long plus attachments.

Attachments:
BookInventoryConsole.txt (2K) (Preview)
BookInventoryUseNotes.txt (9K) (Preview)
consoleOutputPrnScr.JPG (32K) (Preview)
BookInventoryZipped.zip (40K)
   
Join Now or Log In
Get Tutoring
Get Paid
Academic Honesty