Question: This problem contains several steps: 1. Design an interface named Colorable with a public void method named howToColor(). Every class of a colorable object must

 This problem contains several steps: 1. Design an interface named Colorable

This problem contains several steps: 1. Design an interface named Colorable with a public void method named howToColor(). Every class of a colorable object must implement this interface. 2. Design a new class named Square that extends GeometricQbject (available from http://www.cs.armstrong.edu/liang/intro10e/html/GeometricObject.htm 1) and implements the Colorable interface. Define the bowToColorC) method for a Square so that it prints a brief message on how to color the square (for now, this message can be anything you want, even something silly like "Use a blue crayon"). Implement a class named Triangle that extends does NOT implement the Colorable interface). To speed things up, just provide stubs ("placeholder" methods used for testing purposes) for the two methods that every GeometricQbiect subclass must implement getArea() and getPerimeter). For now, each of these methods should always return 1.0. Write a test program that creates an array of five GeometricQbiects (a mixture of Square and Triangle objects). For each object in the array, if it is colorable, invoke its bowToColor0) method. 3. (but 4. Hint: Use Java's instanceof operator here to determine whether a GeometricQbiect is also a Colorable object. For example: if (x instanceofColorable) // Add Colorable-specific code here

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!