Question: Define two derived classes of the abstract class ShapeBase in Your two classes will be called RightArrow and LeftArrow. These classes will be like the

Define two derived classes of the abstract class ShapeBase in Your two classes will be called RightArrow and LeftArrow. These classes will be like the classes Rectangle and Triangle, but they will draw arrows that point right and left, respectively. For example, the following arrow points to the right:

Abstract base class for drawing simple shapes on the screen using characters.

The size of the arrow is determined by two numbers, one for the length of the lair and one for the width of the arrowhead. (The width is the length of the vertical base.) The arrow shown here has a length of 16 and a width of 7. The width of the arrowhead cannot be an even number, so your constructors and mutator methods should check to make sure that it is always odd. Write a test program for each class that tests all the methods in the class. You can assume that the width of the base of the arrowhead is at least 3.

The Abstract Class ShapaBase

public abstract class ShapeBase implements ShapeInterface { private int offset; public abstract

Abstract base class for drawing simple shapes on the screen using characters. public abstract class ShapeBase implements ShapeInterface { private int offset; public abstract void drawHere(); The rest of the class is identical to ShapeBasics in Listing 8.12, except for the names of the constructions. Only the method drawHere is abstract. Methods other than drawHere have bodies and do not have the keyword abstract in their headings. We repeat one such method here: public void drawAt(int lineNumber) { } for (int count = 0; count < lineNumber; count++) System.out.println(); drawHereO;

Step by Step Solution

3.32 Rating (152 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To implement the classes RightArrow and LeftArrow derived from the abstract class ShapeBase follow the steps below These classes will be responsible f... View full answer

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 Programming Questions!