Turtlegraphics with Java
HomeAufgabenDruckenJava-Online
Unbenanntes Dokument

Serie 11: Threads


1)

Two Turtles simultaneously draw a figure consisting of squares of different sizes.

 

 

2)

A new turtle is created with each mouse click and this draws a star. As each turtle draws in its own thread, any number of drawing turtles can be created at the same time.


 

 

3)

In series 8 you solved the following task:
Two Turtles move with random distances and random angles
e.g.: left(-180 + 360 * Math.random()). If they come too close to each other, a sound is emitted, the two Turtles delete their tracks and then move randomly again.
Without using threads, two Turtles cannot move at the same time. They draw alternately.

A) Solve this task with threads so that the two Turtles draw the random tracks simultaneously and not one after the other.

B) The Turtles do not move randomly, but towards each other, each by a short distance. Use threads again to solve this task.