import java.awt.*;
/** Assignment A4: using a Turtle */
public class YourTurtle extends Turtle {
    /** Draw a black line 30 pixels to the right and then
     a green line 35 pixels down. */
    public void drawTwo() {
        move(30); // draw a line 30 pixels to the right
        addAngle(270); // add 270 degrees to the angle
        setColor(Color.green);
        move(35);
    }
    
    /** Draw a 7-pointed star of side-length d */
    public void drawStar(int d) {
        for (int i= 1; i <= 7; i= i+1) {
            move(d);
            addAngle(154.28571428571428);
        }
    }
    
    /** Draw a 7-pointed star of side-length d at the current
        position with a point headed up.*/
    public void drawStarUp(int d) {
        setAngle(0);
        drawStar(d);
    }
    
    /**  (1) Clear the drawing frame, (2) move the turtle (without drawing) to
         the middle of the frame and face it east, and (3) Draw a spiral of n
         lines, using an angle of a, with the first line having length d, and
         pausing sec nanoseconds after each line.
         The lines alternate between red, green, and blue.*/
    public void spiral(int n, double a, int d, int sec) {
        clear();
        moveTo(getWidth()/2, getHeight()/2,0);
        
        Color save= getColor();
        for (int i= 1; i <= n; i= i+1) {
            if (i%3 == 0) setColor(Color.red);
            else if (i%3 == 1) setColor(Color.green);
            else setColor(Color.blue);
            move(d*i);
            addAngle(a);
            pause(sec);
        }
        setColor(save);
    }
    
    
}