I need to create two classes LeftArrow and RightArrow class that are child class
ID: 3531811 • Letter: I
Question
I need to create two classes LeftArrow and RightArrow class that are child classes of the ShapeBase class in java.
Each of these two classes need to draw a left and right arrow using asterisks.
I can't display the code without it messing up the page.
All I need is to figure out the logic to display the arrow left or right.
************************************************************************
public abstract class ShapeBase implements ShapeInterface
{
private int offset;
public ShapeBase( )
{
offset = 0;
}
public ShapeBase(int theOffset)
{
offset = theOffset;
}
/**
Draws the shape at the current line.
*/
public abstract void drawHere( );
/**
Draws the shape at lineNumber lines down
from the current line.
*/
public void drawAt(int lineNumber)
{
for (int count = 0; count < lineNumber; count++)
System.out.println( );
drawHere( );
}
public void setOffset(int newOffset)
{
offset = newOffset;
}
public int getOffset( )
{
return offset;
}
}
Explanation / Answer
public abstract class ShapeBase implements ShapeInterface
{
private int offset;
public abstract void drawHere();
.
.
.
public void draw At(int lineNumbers)
{
for(int count = 0; count < lineNumber; count++)
System.out.println();
drawHere();
}
}
public interface ShapeInterface
{
//Sets the offset for the shape
public void setOffset(int new Offset);
//Returns the offset for the shape
public int getOffset();
//Draws the shape at lineNumber lines
down from current line position
public void drawAt(int lineNumber);
//Draws the shape at the current line
public void drawHere();
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.