Commit 742cee26 by Patryk Czarnik

wielokąt żółwiem

parent d9ba5dab
package turtle;
public class Kwadrat {
public static void main(String[] args) {
Turtle turtle = new Turtle();
/*
turtle.forward(100);
turtle.left(90);
turtle.forward(100);
turtle.left(90);
turtle.forward(100);
turtle.left(90);
turtle.forward(100);
turtle.left(90);
*/
for(int i = 0; i < 4; i++) {
turtle.forward(100);
turtle.left(90);
}
}
}
package turtle;
import javax.swing.JOptionPane;
public class Wielokat {
public static void main(String[] args) {
final int OBWOD = 2000;
int n = Integer.parseInt(JOptionPane.showInputDialog("Podaj liczbę boków"));
double kat = 360.0 / n;
double bok = (double)OBWOD / n;
// za pomocą żółwia narysuj wielokąt foremny o tylu wierzchołkach / bokach
Turtle.setCanvasSize(OBWOD / 2, OBWOD / 2);
Turtle t = new Turtle(-bok/2, -OBWOD/(Math.PI * 2));
t.penColor("blue");
t.width(5);
for(int i = 0; i < n; i++) {
t.forward(bok);
t.left(kat);
}
}
}
package turtle;
import javax.swing.JOptionPane;
public class Wielokat_v1 {
public static void main(String[] args) {
int n = Integer.parseInt(JOptionPane.showInputDialog("Podaj liczbę boków"));
// za pomocą żółwia narysuj wielokąt foremny o n bokach
Turtle turtle = new Turtle();
double kat = 360.0 / n;
for(int i = 0; i < n; i++) {
turtle.forward(100);
turtle.right(kat);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment