Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Instructions 1. Create an abstract class named Book. Include a String field for the Book's title and a double field for the book's price. Within

image text in transcribed

image text in transcribed

Instructions 1. Create an abstract class named Book. Include a String field for the Book's title and a double field for the book's price. Within the class, include a constructor that requires the book title, and two get methods-one 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. 2. 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. 3. 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 Nonfiction Book Title Price

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_2

Step: 3

blur-text-image_3

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

Oracle RMAN For Absolute Beginners

Authors: Darl Kuhn

1st Edition

1484207637, 9781484207635

More Books

Students also viewed these Databases questions

Question

U11 Informing Industry: Publicizing Contract Actions 317

Answered: 1 week ago