Turtlegraphics for Smartphones and Tablets

Bern University of Teacher Education  
HomeStart Online EditorPrintAndroid GamesJava-Online

Serie 4: if-else-structure, colours

Draw the following figures

1)
adddde: 

Edit source with online-compiler


2)


 

Use the methods:

setPos(x, y) to set the beginning point of each line and

moveTo(x, y) to set the end point of each line

draft:

Edit source with online-compiler

 


3)


  The areas can be coloured with the aid of fillToHorizontal(y).
See example Tu5a.java under use colours.

4)
Use the switch-structure to draw the adjoining figure with different colours. For the colouring out of the squares you may use the method fillToPoint(x, y). By using getX() and getY() the current position of the turtle can be requested.  

As a draft you can use the following example:

Edit source with online-compiler