Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design and implement a set of classes that define various types of reading material. Start by defining a parent class called Reading Material. This class

image text in transcribedimage text in transcribed

Design and implement a set of classes that define various types of reading material. Start by defining a parent class called Reading Material. This class should contain the following instance variables: . title - a String containing the title of the reading material author - a String containing the author of reading material numPages - an integer containing the number of pages in the reading material All three variables should be initialized with values passed into the constructor. ReadingMaterial should also have two functions: is Long - takes no parameters and returns a boolean. If the book has more than 250 pages, this function should return true. Otherwise it returns false. summary - takes no parameters and returns nothing. This function should print out information about the book in the form "[title], written by [author]". Three classes should inherit from Reading Material: Novel, Graphic Novel, and Article. The Novel class should have the following specifications: An instance variable called characters that contains an array of Strings with the names of the principle characters in the novel (this variable should be initialized with a value passed into the constructor, along with the novel's title, author, and number of pages). A function called listCharacters which prints out the name of all the primary characters in the order that they are listed, each on their own line. The Article class should have the following specifications: A String instance variable called publication that indicates which publication the article was published in. This should be initialized in the constructor. An overridden version of the summary function that prints out information about the article in the folowing form: "[title], written by [author), published in [publication)" The GraphicNovel class should inherit directly from the Novel class and have the following specifications: A String instance variable called illustrator that contains the name of the person who illustrated the Graphic Novel. (This variable should be initialized with a value passed into the constructor, along with the novel's title, author, and number of pages, and main characters.) An overridden version of the summary function that prints out information about the book in the following form: "[title], written by [author], illustrated by [illustrator]." Test the classes in a Driver class. Make one of each object: A Novel, harry Potter, with the title Harry Potter, author JK Rowling, 303 pages, and the main characters Harry Potter, Hermione Granger, Ronald Weasley, and Voldemort. A GraphicNovel, avengers, with the title Avengers, author Stan Lee, 50 pages, the characters Iron Man, Captain America, Black Widow, The Hulk, and Thor, and the illustrator Jack Kirby. An Article, pc, with the title The Social Meaning of the Personal Computer, author Bryan Pfaffenberger, 10 pages, and the publication Anthropological Quarterly. In the Driver class, print out the summary of harry Potter, the result of harrypotter's isLong function, the list of characters in avengers, the summary of avengers, the result of pc's is Long function, and the summary of pc, with each item on its own line

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

Expert Performance Indexing In SQL Server

Authors: Jason Strate, Grant Fritchey

2nd Edition

1484211189, 9781484211182

More Books

Students also viewed these Databases questions

Question

3 How exchange rates are determined in currency markets.

Answered: 1 week ago

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago