Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create an abstract class named Book. Include a String field for the Books title and a double field for the books price. Within the class,

Create an abstract class named Book. Include a String field for the Books title and a double field for the books price. Within the class, include a constructor that requires the book title, and two get methodsone that returns the title and one that returns the price. Include an abstract method named setPrice(double). Finally, override the toString() method to return a string representation of the book title and price. Save the file as LastNameBook.java. Create two child classes of Book: Fiction and Nonfiction. Each must include a setPrice(double) method that sets the price for each fiction and non-fiction book to a value passed by the user. Write a constructor for each subclass, and include a call to setPrice(double) within each. Save the files as LastNameFiction.java and LastNameNonfiction.java. Write an application named BookDemo in which you read from a file containing a list of books. The file will have a list of fiction and nonfiction books (at least 20 books should be on the list; 10 books of each type). Based on the category (fiction or nonfiction), create the appropriate book object type and store each book in a Java array of objects (you will need two arrays: One for the fiction object and another one for the nonfiction object). Each array will hold a maximum of 10 books. Write a function (or two) to output (print) the details about all fiction and nonfiction books that were read from the file. Print each kind of object using the object name. Save the file as LastNameBookDemo.java. Your program must also work with my book textfile. The format of the text file containing the book list file will contain the book title, price, and category (Fiction or Nonfiction). For example: 20 Years Later,12.99,Fiction To Kill a Mockingbird,10.99,Fiction Against All Odds: A True Story of Ultimate Courage and Survival in World War II,13.49,Nonfiction

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions

Question

Describe the important elements of an orientation program.

Answered: 1 week ago