- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashedLine.java
More file actions
Latest commit
33 lines (30 loc) · 841 Bytes
/
Copy pathdashedLine.java
File metadata and controls
33 lines (30 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
publicclassdashedLine {
publicstaticvoidmain(String[] args) {
Turtlecarl = newTurtle();
//dashedLine(carl, 400, 7);
//carl.color("red");
//carl.backward(400);
dashedPolygon(carl, 100, 7, 5);
carl.penup();
carl.forward(200);
carl.pendown();
dashedPolygon(carl, 150, 5, 6);
}
// draws dashed line
publicstaticvoiddashedLine(Turtlet, doublelength, intnumDashes) {
for (inti = 0; i < numDashes - 1; i++) {
t.forward(length / (2 * numDashes - 1));
t.penup();
t.forward(length / (2 * numDashes - 1));
t.pendown();
}
t.forward(length / (2 * numDashes - 1));
}
// draws dashed polygon
publicstaticvoiddashedPolygon(Turtlet, doublelength, intnumDashes, intnumSides) {
for (inti = 0; i < numSides; i++) {
dashedLine(t, length, numDashes);
t.left(360.0 / numSides);
}
}
}