在Java中如何制作星号的左箭头?

在Java中如何制作星号的左箭头?,java,extends,shapes,implements,Java,Extends,Shapes,Implements,我正在开发一个制作左右箭头的程序。它们是从ShapeBase类扩展而来的,ShapeBase类是从ShapeInterface实现的。我没有粘贴它们,这样看起来就不会让人不知所措。问题是我已经算出了右箭头(我相信),但找不到得到左箭头的方法。我一直感到困惑,似乎不明白怎么做。感谢您的帮助。 公共抽象类ShapeBase实现ShapeInterface { 私有整数偏移; 公共形状库() { 偏移量=0; } 公共形状库(内部偏移) { 偏移量=偏移量; } 公共摘要无效(此处为(); 公共作废

我正在开发一个制作左右箭头的程序。它们是从ShapeBase类扩展而来的,ShapeBase类是从ShapeInterface实现的。我没有粘贴它们,这样看起来就不会让人不知所措。问题是我已经算出了右箭头(我相信),但找不到得到左箭头的方法。我一直感到困惑,似乎不明白怎么做。感谢您的帮助。

公共抽象类ShapeBase实现ShapeInterface
{
私有整数偏移;
公共形状库()
{
偏移量=0;
}
公共形状库(内部偏移)
{
偏移量=偏移量;
}
公共摘要无效(此处为();
公共作废图纸(内部线号)
{
对于(int count=0;count对于(int i=0;i这是绘制左箭头的方式,它不使用您的方法(因为您没有为
ShapeBase
)提供源代码),但您可以看到下面的实现如何创建它,然后以您自己的方式使用它

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();
    }
}
公共类LeftArrow
{
私人int tail=15;
私有整数宽度=7;
//方法来绘制左箭头
公共空间箭头()
{

对于(int i=0,r=0;我感谢您尝试帮助我。我将ShapeBase类添加到了我的问题中,如果您能再次查看它,我宁愿不要删除我已经完成的大量工作。有很多代码。如果您能更好地了解上面的代码如何工作,那么您就可以实现自己的
ArrowTail()
bottomArrowHead()
方法。
    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(" ");
        }
}
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();
    }
}