-1
右矢印と左矢印を作るプログラムを作っています。これらは、ShapeInterfaceから実装されたShapeBaseクラスから拡張されています。圧倒されないように貼り付けなかった。問題は、私は右の矢を(私は信じている)考え出したが、左矢印を得るための自分の道を見つけることができないということです。私は混乱し続けるし、それを行う方法を理解していないようです。どんな助けもありがとうございます。左矢印CLASS FOR RightArrow Example OutputJavaでアスタリスクの左矢印を作成するにはどうすればよいですか?
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(" ");
}
}
、私はこれらが唯一の方法が変化する必要があると考えています。 私はちょうどこれを使用すると、左の矢印を描くことができる方法であるか
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(" ");
}
}
ありがとうございました。私はShapeBaseクラスを私の質問に追加しました。あなたがもう一度それを見直すことができたら、私はすでに多くの仕事を消していません。 –
多くのコードがあります。どのように動作するのか上のコードを見ると、あなたはurの独自メソッドArrowTail()とbottomArrowHead()を実装することができます。 –
もう一度ありがとう –