Create 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 add two get methods – one that returns the title and one that returns the price( ). Create two child classes of Book: Fiction and NonFiction Books. Each must include a setPrice( ) method that sets the price for all Fiction Books to $24.99 and for all NonFiction Books to $37.99. Write a constructor for each subclass, and include a call to setPrice( ) within each. Display the type, title, and price for the two classes of book you have coded.Write an application demonstrating that you can create both a Fiction and a NonFiction Book, and display their fields. Save the Book.java, Fiction.java, NonFiction.java and UseBook.java files in particular folder.
Fiction:
Scarlet Letter, Mill on the Floss, The Road Not Taken, A Tale of Two Cities, War and Peace, A Simple Plan, Disclosure, Nancy Drew
NonFiction:
Europe on $5 a Day, Introduction to Java
Tags: