Übungen: Mustererzeugen Januar 19 Grundkurs Informatik
public void zeichne() { maler.right(270); Konzentrische Kreise public void zeichne() { maler.right(270); for (int i = 0; i < 15; i++){ maler.jumpTo(0,10*i); maler.circle(10*i); } Januar 19 Grundkurs Informatik
public void zeichne() { double x = -150, y = 100; while(x<=150){ Quadrate public void zeichne() { double x = -150, y = 100; while(x<=150){ maler.jumpTo(x,y); maler.moveTo(x,-100); x += 20; } x = -150; y = 100; while(y>=-100){ maler.moveTo(150,y); y -= 20; Deklarieren und setzten der Ausgangsposition Schleife für die senkrechten Striche Zurück zur Ausgangsposition Schleife für die waagerechten Striche. Januar 19 Grundkurs Informatik
Muster public void zeichne() { for (int x = -150; x<= 150;x+=25){ for (int y = 150; y > -150 ; y-=25){ maler.jumpTo(x,y); maler.right(90); maler.forward(20); maler.forward(15); maler.forward(10); maler.forward(5); maler.right(270); maler.right(180); }}} Januar 19 Grundkurs Informatik
Erzeugen, Positionieren, Färben und Benennen der 4 Katzen 4 cool cats public FourCoolCats(String title) { super(title); mimi = new Turtle(tWin); mimi.jumpTo(-100,100); mimi.setColor(Color.MAGENTA); mimi.writeTo("Mimi",-120,110); tiger = new Turtle(tWin); tiger.jumpTo(100,100); tiger.setColor(Color.RED); tiger.writeTo("Tiger",80,110); morle = new Turtle(tWin); morle.jumpTo(100,-100); morle.setColor(Color.BLACK); morle.writeTo("Morle",80,-120); pavarotti = new Turtle(tWin); pavarotti.jumpTo(-100,-100); pavarotti.setColor(Color.BLUE); pavarotti.writeTo("Pavarotti",-120,-120); } Erzeugen, Positionieren, Färben und Benennen der 4 Katzen Januar 19 Grundkurs Informatik
4 cool cats public void zeichne() { while(Math.round(mimi.getX())!=0 ||Math.round(mimi.getY())!=0){ mimi.turnTo(tiger.getX(),tiger.getY()); mimi.forward(1); tiger.turnTo(morle.getX(),morle.getY()); tiger.forward(1); morle.turnTo(pavarotti.getX(),pavarotti.getY()); morle.forward(1); pavarotti.turnTo(mimi.getX(),mimi.getY()); pavarotti.forward(1); } Januar 19 Grundkurs Informatik