B1

package sk.paz1a.practicals.task1;

import java.awt.Color;

import sk.upjs.jpaz2.*;

public class Launcher {

        public static void main(String[] args) {
                // create new "sandbox" - a place where turtles can live
                AnimatedWinPane sandbox = new AnimatedWinPane();

                // create new turtle and add it to the "sandbox"
                SmartTurtle franklin = new SmartTurtle();
                sandbox.add(franklin);

                // create new object inspector
                ObjectInspector oi = new ObjectInspector();
                // ask the inspector to inspect "franklin" and "sandbox"
                oi.inspect(franklin);
                oi.inspect(sandbox);

                // you can put other initialization commands here

                franklin.setPosition(100, 150);
                franklin.setPenColor(Color.BLUE);

                // 1. vytvorim korytnacku ktora sa vola cecil
                Turtle cecil = new Turtle();
                // 2. pridam cecila do plochy
                sandbox.add(cecil);
                // 3. bude ju skumat OI
                oi.inspect(cecil);
                // 4. nastavim poziciu
                cecil.setPosition(200, 150);
                // 5. farba cervena
                cecil.setPenColor(Color.RED);

                franklin.square();
                franklin.triangle(50);

        }
}
package sk.paz1a.practicals.task1;

import sk.upjs.jpaz2.*;

public class SmartTurtle extends Turtle {

        public void square() {
                for (int i = 0; i < 4; i++) {
                        this.step(75);
                        this.turn(90);

                }
        }

        public void triangle(double size) {
                for (int i = 0; i < 3; i++) {
                        this.step(size);
                        this.turn(120);
                }
        }
}