Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can I get a little assistance with this one? Introduction to Abstract Classes This exercise is designed to introduce you to the concept of inheritance

Can I get a little assistance with this one?

image text in transcribedimage text in transcribed

Introduction to Abstract Classes This exercise is designed to introduce you to the concept of inheritance using an abstract class You are to design three classes, a base class and two derived classes according to the specifications below I. Create an abstract class named Books Fields: title - a String field price- a float field Constructors: A default constructor A constructor with two arguments, title and price. Two getters, one for each field of the class toString0, an abstract method Methods II. Create a subclass named Fiction: Field numPages - an integer field Constructors: A constructor with two arguments, the title and the number of pages that sets the price to a default value of $27.95 A constructor with three arguments, the title, number of pages and the price. Getter methods for the class field toStringO- to display all the field values Create a subclass named NonFiction: Methods Field: topic a String field to describe the topic area of the book (e.g.: History Biography, Science, etc.) Constructors: A constructor with two arguments, the title and the topic that sets the price to a default value of $34.75 A constructor with three arguments, the title, the topic and the price. Getter methods for the class field toString0- to display all the field values Methods

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

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions

Question

Are you creative or practical?

Answered: 1 week ago