Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java triangle programs

807600Oct 23 2007 — edited Oct 23 2007
I have to write two programs that draw two arrows, one that points right, and one that points left. according to the assignment the program must have two drived classes. one called right arrow and one called left arrow.

this is what I have and its not even compiling:

public class leftarrow
{
private int base;

public Triangle()
{
super();
base = 0;
}

public Triangle(int theoffset, int thebase)
{
super(theoffset);
base = thebase;
}

public void reset(int newoffset, int newbase)
{
setoffset(newoffset);
base = newbase;
}

public void drawbase()
{
spaces(getoffset());
int count;
for (count = 0; count < base; count++)
System.out.print("*");
System.out.println();
}

private void drawTop()
{
int startOfLine = getOffset() + (base/2);
spaces(startOfLine);
System.out.println("*");
int count;
int lineCount = (base/2) - 1;
int insideWidth = 1;
for (count = 0; count < lineCount; count++)
{
startOfLIne--;
spaces(startOfLine);
System.out.print("*");
spaces(insideWidth);
System.out.println("*");
insideWidth = insideWidth + 2;
}
}

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

}

I would appreciate any help you experts could give me
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 20 2007
Added on Oct 23 2007
16 comments
288 views