Im new to java so please give me a chance.I got some code from university but it just doesnt seem to work, I thought my problem was a spelling mistake but when i fix 1 problem i ca get many more and they dnt make any sence....
the programs split into 4 parts,
public class GraphicsDemo { public static final int indent = 5; public static final int topWidth = 21; public static final int bottomWidth = 4; public static final int bottomHeight = 4; public static void main(String[] args) { System.out.println(" Save the Redwoods!"); Triangle top = new Triangle(indent, topwidth); Box base = new Box(indent + (topWidth/2) (bottomWidth/2), bottomHeight, bottomWidth); top.drawAt(1); base.drawAt(0); } }
Next is
public class Triangle extends Figure { 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 drawHere() { drawTop(); drawBase(); } private 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(' '); } }
next is:
public class Figure { private int offset; public Figure() { offset = 0; } public Figure(int theOffset) { offset = theOffset; } public void setOffset(int newOffset) { offset = newOffset; } public int getOffset() { return offset; } public void drawAt(int lineNumber) { int count; for (count = 0; count < lineNumber; count++) System.out.println(); } public void drawHere() { int count; for(count = 0; count < offset;count++) System.out.print(' '); System.out.println('*'); } }
next is:
public class Box extends Figure { private int height; private int width; public Box() { super(); height = 0; width = 0; } public Box( int theOffset, int theHeight, int theWidth) { super(theOffset); height = theHeight; width = theWidth; } public void reset( int newOffset, int newHeight, int newWidth ) { setOffset(newOffset); height = newHeight; width = newWidth; } public void drawHere() { drawHorizontalLine(); drawSides(); drawHorizontalLine(); } private void drawHorizontalLine() { spaces(getOffset()); int count; for (count = 0; count < (height -2); count++) System.out.println('-'); System.out.println(); } private void drawSides() { int count; for (count = 0; count < (height - 2); count++) drawOneLineOfSides(); } private void drawOneLineOfSides() { spaces(getOffset()); System.out.println('|'); spaces(width - 2); System.out.println('|'); } private static void spaces(int number) { int count; for (count = 0; count < number; count++) System.out.print(' '); } }
My error/s are in graphics demo but aremany different ones,
just wondering can anyone spot any mistake, thanks