Reader - Reader.java This program reads various types of ReadingMaterial such as Novels Books Magazines and Textbooks The above objects are arranged in

Reader - Reader.java This program reads various types of...

This preview shows page 1 - 2 out of 3 pages.

//********************************************************************************************//// Reader.java//// This program reads various types of ReadingMaterial, such as Novels, Books, Magazines,// and Textbooks. The above objects are arranged in an inheritance hierarchy, like so:////ReadingMaterial/// \ /// \ /// Book/// / \/// / \//Magazine Novel Textbook////********************************************************************************************public class Reader {//// Creates some objects from the ReadingMaterial class hierarchy and displays// them to the user//public static void main(String args[]) {ReadingMaterial theNovel = new Novel("The Hobbit", "J.R.R. Tolkien","Ballantine Books, Inc.", 287, "Bilbo Baggins", "Gandalf the Grey");Comparable newBook = new Comparable("How to Comb Your Hair in 37 Different Ways", "The Comb Man", "Plastics, Inc.", 38);Textbook chemistryBook = new Textbook("Introductory Chemistry", "Some chemistry guy", "ChemWorldBigCorp Inc.", 5000000, "chemistry");ReadingMaterial geekWorld = new Magazine("Geek World", "John Lewis","computers and other geeky things", "March 2050", 128);System.out.println("I finished reading " + (Novel)theNovel + ". It'spretty good.");System.out.println("I read " + newBook + ", too. It's not very interesting.");System.out.println("I was supposed to read " + chemistryBook + ",

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture