A1

Streda

package paz1a.juraj.sebej.task01;

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);

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

                Turtle cecil = new Turtle();
                sandbox.add(cecil);
                cecil.setPosition(200, 150);
                cecil.setPenColor(Color.RED);

                oi.inspect(cecil);

                SmartTurtle albert = new SmartTurtle();
                sandbox.add(albert);
                oi.inspect(albert);

        }
}
package paz1a.juraj.sebej.task01;

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);
                }
        }

}
 

Stvrtok

package paz1a.juraj.sebej.task01;

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);

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

                Turtle cecil = new Turtle();
                sandbox.add(cecil);
                cecil.setPosition(200, 150);
                cecil.setPenColor(Color.RED);

                oi.inspect(cecil);

                SmartTurtle albert = new SmartTurtle();
                sandbox.add(albert);
                oi.inspect(albert);

                franklin.rgbTriangle(100);

        }
}
package paz1a.juraj.sebej.task01;

import java.awt.Color;

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);
                }
        }

        public void centeredSquare(double sideLength) {
                this.step(sideLength);
        }

        public void filledSquare(double size) {
                this.penUp();
                this.openPolygon();
                for (int i = 0; i < 4; i++) {
                        this.step(size);
                        this.turn(90);
                }
                this.closePolygon();
                this.penDown();
        }

        public void rgbTriangle(double size) {
                this.setPenWidth(2);
                this.setPenColor(Color.red);
                this.step(size);
                this.turn(120);
                this.setPenColor(Color.green);
                this.step(size);
                this.turn(120);
                this.setPenColor(Color.blue);
                this.step(size);
                this.turn(120);
        }

}

Študentský kód od Sofie

package sk.paz1a.practicals.task1;

import java.awt.Color;

import sk.upjs.jpaz2.*;

public class SmartTurtle extends Turtle {

// put new methods here
        public void square75() {
                for (int i = 0; i < 4; i++) {
                        this.step(75);
                        this.turn(90);
                }
        }

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

        public void rgbTriangle(double size) {
                this.setPenWidth(2);
                this.setPenColor(Color.RED);
                this.step(size);
                this.turn(120);
                this.setPenColor(Color.GREEN);
                this.step(size);
                this.turn(120);
                this.setPenColor(Color.BLUE);
                this.step(size);
                this.turn(120);

        }

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

        public void rectangle(double size1, double size2) {
                for (int i = 0; i < 2; i++) {
                        this.step(size1);
                        this.turn(90);
                        this.step(size2);
                        this.turn(90);
                }
        }

        public void house(double size) {
                this.square(size);
                this.step(size);
                this.triangle(size);
                this.turn(150);
                this.step(size);
                this.turn(180);
        }

        public void dasDotDash(double lenght) {
                this.step(lenght / 4);
                this.penUp();
                this.step(lenght / 4);
                this.penDown();
                this.dot(lenght / 8);
                this.penUp();
                this.step(lenght / 4);
                this.penDown();
                this.step(lenght / 4);
        }

        public void centeredSquare(double sideLength) {
                this.penUp();
                this.step(sideLength / 2);
                this.turn(270);
                this.step(sideLength / 2);
                this.turn(180);
                this.penDown();
                for (int i = 0; i < 4; i++) {
                        this.step(sideLength);
                        this.turn(90);
                }
                this.penUp();
                this.step(sideLength / 2);
                this.turn(90);
                this.step(sideLength / 2);
                this.turn(180);
        }

        public void filledSquare(double size) {
                this.penUp();
                this.openPolygon();
                for (int i = 0; i < 4; i++) {
                        this.step(size);
                        this.turn(90);
                }
                this.closePolygon();
                this.penDown();
        }

        public void sun(double radius) {
                this.setPenColor(Color.ORANGE);
                for (int i = 0; i < 36; i++) {
                        this.step(radius * 2);
                        this.step(-(radius * 2));
                        this.turn(10);
                }
                this.setFillColor(Color.YELLOW);
                this.dot(radius);
        }

        public void pinwheel(double size) {
                for (int i = 0; i < 8; i++) {
                        this.step(size);
                        this.turn(45);
                        this.step(10);
                        this.step(-10);
                        this.turn(-45);
                        this.step(-size);
                        this.turn(360 / 8);
                }
        }

        public void cross(double size) {
                this.setPenWidth(2);
                this.setPenColor(Color.RED);
                for (int i = 0; i < 4; i++) {
                        this.step(size);
                        this.turn(270);
                        this.step(size);
                        this.turn(90);
                        this.step(size);
                        this.turn(90);
                }
        }
}