Reference no: EM13162450
Define two derived classes of the abstract class ShapeBase below. Your two classes will be called RightArrow and LeftArrow. These classes will draw arrows that point right and left, respectively. The size of the arrow is determined by two numbers, one for the length of the tail and one for the width of the arrowhead. These values are 16 and 7 in the above display. 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 methods in the class. You can assume the width of the base of the arrowhead is at least 3.
*
* *
* *
**************** *
* *
* *
*
// Base class (ShapeBase)
public abstract class ShapeBase implements ShapeInterface{
protected int offset;
// I made offset protected so that the subclasses can refrence it directly
public void setOffset(int newOffset)
{
offset = newOffset;
}
public int getOffset()
{
return offset;
}
public abstract void drawHere();
public void drawAt(int lineNumber)
{
for(int i=0; i<lineNumber; i++)
System.out.println();
drawHere();
}
}
// Shape Interface
public interface ShapeInterface{
public void setOffset(int offset);
public int getOffset();
public void drawAt(int lineNumber);
public void drawHere();
}