Hi. I am kinda new to java and I really need help on this program that I have been assigned. Here is the assignment:
Assignment: Write a KochCurve program that uses DrawingTool and provides a drawKochCurve method for drawing Koch curves. Each drawKochCurve method can take the number of levels and an initial size as its parameters.
Somehow, my code compiles but when I run it, nothing shows up. Can someone please help me. I would really appreciate it.
import gpdraw.*;
public class KochCurve {
private DrawingTool pen;
private SketchPad paper;
public KochCurve(){
paper = new SketchPad(500,500);
pen = new DrawingTool(paper);
}
public void drawKochCurve(int level, int length) {
if (level < 1)
pen.forward(length);
else {
drawKochCurve(level - 1, length / 3);
pen.turnLeft(60);
drawKochCurve(level - 1, length / 3);
pen.turnRight(120);
drawKochCurve(level - 1, length / 3);
pen.turnLeft(60);
drawKochCurve(level - 1, length / 3);
}
}
public static void main(String[] args) {
KochCurve curve = new KochCurve();
curve.drawKochCurve(6,300);
}
}