public class TurtleDance{
private Turtle[] turtles; //instance variable An Array of Turtles
private World stage; //instance varialbe The world
private int count; //the number of milliseconds in one "beat"
public TurtleDance() //constructor. Initialize the array of Turtles
{
Turtle[] turtles = new Turtle[7];
World stage = new World(900,600);
count = 500;
for(int x=0;x<turtles.length;x++)
{
for(int posx = 150;posx<850;posx = posx + 100)
{
turtles[x] = new Turtle(posx,300,stage);
if(x == 3)
turtles[x].setColor(red);
}
}
}
/* you can make every other turtle move by using a loop like this:
* for(int x = 1;x<dancers.length;x*=2)
* {
* //blah
* }
*
* you don't always have to move all turtles together. You can still move a sinlge turtle at a time
* by using a literal int as an index (ex. dancers[2]) So maybe you want one turtle to have a solo
*
*
* */
public void allForward(int dist)//makes all turtles in your array move forward d pixels
{
for(int x = 0;x<turtles.length;x++)
turtles[x].forward(dist);
}
public void allTurn(int degrees)//makes all turtles in your array turn degrees
{
}
//////////////////////////////////////////////////////////////////////////////////////
public void dance() //the "script" of your turtle dance
{
}
////////////////////////////////////////////////////////////////////////////
private void wait(int milliseconds) //helper method that causes a program to wait
{ //the given number of ms. You can use this in future programs too.
try{
Thread.sleep(milliseconds);
}
catch(Exception e)
{}
}
/////////////////////////////////////////////////////////////////////////
public static void main(String[] args)
{
TurtleDance a = new TurtleDance();
a.allForward(30);
}
}