-1

I'am working on a program that makes right and left arrows. They are extended from a ShapeBase class which is implemented from a ShapeInterface. I didn't paste them so it wouldn't look overwhelming. The problem is I have figured out the right arrow ( I believe) but cannot find my way to getting the left arrow. I keep getting confused and cant seem to understand how to do it. Any help is appreciated. RightArrow Example Output

public abstract class ShapeBase implements ShapeInterface
{
private int offset;

public ShapeBase( )
{
    offset = 0;
}

public ShapeBase(int theOffset)
{
    offset = theOffset;
}

public abstract void drawHere( );

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;
}
}





public class RightArrow extends ShapeBase
{
private int tail;
private int width;

public RightArrow()
{
    super();
    tail = 0;
    width = 0;
}

public RightArrow(int theOffset ,int tailSize, int theWidth)
{
    super(theOffset);
    tail = tailSize;
    width = theWidth;
    set(tail , width);
}
public void set(int newHeight, int newWidth)
{
    tail = newHeight;
    width = newWidth;
}

public void drawHere()
{
    topArrowhead();
    ArrowTail();
    bottomArrowHead();
}
public void topArrowhead()
{
    skipSpaces(getOffset());
    System.out.println("*");

    for(int i = 0; i<width/2; i++)
    {
        skipSpaces(getOffset());
        System.out.print("*");
        skipSpaces(i);
        System.out.println("*");
    }
}

// method to draw the arrow tail
public void ArrowTail()
{
    for(int count=0; count<tail; count++)
    {
        System.out.print("*");
    }
    skipSpaces(tail+width);
    System.out.print("*");

}

// method to draw bottom of arrowhead
public void bottomArrowHead()
{
    for(int i =1;i<width/2; i--)
    {
        skipSpaces(getOffset());
        System.out.print("*");
        skipSpaces(i);
        System.out.println("*");
    }
    skipSpaces(getOffset());
    System.out.println("*");
}

private static void skipSpaces(int number)
{
    for (int count=0; count< number; count++)
    System.out.print(" ");
}
}

FOR THE LEFT ARROW CLASS, I believe these are the only methods need changing. I just don't know how

    public void topArrowhead()
        {
            skipsSpaces(getOffset());
            System.out.println("*");

            for(int i = 0 i<width/2; i++)
            {
                skipSpaces(getOffset());
                System.out.print("*");
                skipSpaces(i);
                System.out.println("*");
            }
        }

        // method to draw the arrow tail
        public void ArrowTail()
        {

        }

        // method to draw bottom of arrowhead
        public void bottomArrowHead()
        {

        }

        private static void skipSpaces(int number)
        {
            for (int count=0; count< number; count--)
            System.out.print(" ");
        }
}
Mrs.Brightside
  • 115
  • 1
  • 1
  • 12

1 Answers1

0

This is how you can draw a left arrow,it doesn't uses your methods(as you not provided source for ShapeBase) but you can see the implementation below how its get created and then can use in your own way.

public class LeftArrow
{
    private int tail=15;
    private int width=7;

    //Method to draw the left arrow    
    public void DrawArrow()
    {
        for(int i = 0,r=0; i<width; i++)
        {
            //for spaces before head
            for(int j=0;j<(width/2)-r;j++)
                    System.out.print(" ");

            for(int j=0;j<=r;j++)
            {
                if(j==r || j==0)
                System.out.print("*");
                else
                System.out.print(" ");//for spaces inside head
            }
            if(i==width/2)//to draw tail after the mid of head
                ArrowTail();

            if(i<width/2)//controls the increment & decrements of spaces before head
                r++;
            else r--;

            System.out.println();
        }
    }

    // method to draw the arrow tail
    public void ArrowTail()
    {
        for(int count=0; count<tail; count++)
        {
            System.out.print("*");
        }
    }

    public static void main(String[] args)
    {
        LeftArrow Arrow = new LeftArrow();
        Arrow.DrawArrow();
    }
}
Rajeev Singh
  • 3,292
  • 2
  • 19
  • 30
  • thank you for trying to help me. I added the ShapeBase class to my question if you could review it again, I rather not erase a lot of my work already. – Mrs.Brightside Mar 31 '16 at 13:16
  • There is a lot of code.Better you see the code above how it works,then you could be able to implement `ArrowTail()` & `bottomArrowHead()` methods of ur own. – Rajeev Singh Mar 31 '16 at 13:23