018-002-008

Applied Polymorphism: Common Processing

Easy

Problem Description

Applied polymorphism: Common Processing

In this problem, you will create a program that implements the Describable interface in Book and Movie classes, and displays each object's description to standard output through a shared helper method.

Learning Objective: Understand how to apply common processing to different objects using polymorphism

Overview

Implement Describable interface in Book and Movie classes, and output different descriptions through the same method.

Specifications

  1. Declare String describe() in Describable
  2. Book returns Book: Java Programming from describe()
  3. Movie returns Movie: The Matrix from describe()
  4. In main, define a showDescription(Describable d) helper method that prints Description: <d.describe()>
  5. Call with Book and Movie

Output Format

Description: Book: Java Programming
Description: Movie: The Matrix

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up