import chess.Chess;
import chess.RunnableApplet;
import chess.Screen;
import chess.Turtle;
import java.applet.Applet;
import java.awt.Dimension;
import javax.swing.JFrame;

public class TurtleExcerciseFive extends RunnableApplet {
    
    public static void drawStar( Turtle tim, int size ) {
        int sides= 10;
        int angle= 144;
        
        for ( int i=0; i<sides; i++ ) {
            tim.forward(size);
            tim.right(angle);
        }
        
    }
    
    public void init() {
    }
    
    public void run() {
        /* here you go */
        Turtle tim;
        Screen myScreen;
        
        myScreen= Chess.newScreen( this );
        tim= myScreen.newTurtle();
        
        tim.ultraFast();
        int stars= Chess.readInt("Enter the number of stars: ");
        
        int angle= 360 / stars;
        
        for ( int i=0 ; i<stars ; i++ ) {
            
            tim.right(angle);
            tim.penUp();
            tim.forward(50);
            tim.penDown();
            
            tim.setHSVColor( angle*i, 1.0, 1.0 );
            
            drawStar( tim, 50 );
            
            tim.penUp();
            tim.back(50);
            tim.penDown();
            
        }
        
        tim.home();
        
    }
    
        /**
     *  For testing within NetBeans, we define a main method.  This is
     *  ignored when a web page uses the applet.  Here is the code you should
     *  have in your web page:
     *    <applet archive="CHESS.jar"
     *            code="CoinDrag" width="800" height="800" >
     *    </applet>
     *  The file CHESS.jar is found in the folder "dist", and should be
     *  put next to the html file.
     */
    public static void main( String[] args ) {
        JFrame frame= new JFrame("TurtleExerciseFive");
        frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        Applet applet= new TurtleExcerciseFive();
        Dimension appletDimension= new Dimension(800,800);
        applet.setMinimumSize( appletDimension );
        applet.setPreferredSize( appletDimension );
        frame.setContentPane(applet);
        frame.pack();
        frame.setVisible(true);
        applet.init();
        applet.start();
    } //main
    
}
