-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTurtle.java
122 lines (114 loc) · 2.92 KB
/
Turtle.java
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/* Filename: Turtle.java
* Created by: Nick Lin and Robert Tso, CSE8a
* Date: October 6, 2016
*/
import java.util.*;
import java.awt.*;
/**
* Class that represents a turtle which is similar to a Logo turtle.
* This class inherts from SimpleTurtle and is for students
* to add methods to.
*
* Copyright Georgia Institute of Technology 2004
* @author Barb Ericson [email protected]
*/
public class Turtle extends SimpleTurtle {
////////////////// constructors ///////////////////////
/** Constructor that takes the x and y and a picture to
* draw on
* @param x the starting x position
* @param y the starting y position
* @param picture the picture to draw on
*/
public Turtle (int x, int y, Picture picture) {
// let the parent constructor handle it
super(x,y,picture);
}
/** Constructor that takes the x and y and a model
* display to draw it on
* @param x the starting x position
* @param y the starting y position
* @param modelDisplayer the thing that displays the model
*/
public Turtle (int x, int y, ModelDisplay modelDisplayer) {
// let the parent constructor handle it
super(x,y,modelDisplayer);
}
/** Constructor that takes the model display
* @param modelDisplay the thing that displays the model
*/
public Turtle (ModelDisplay modelDisplay) {
// let the parent constructor handle it
super(modelDisplay);
}
/**
* Constructor that takes a picture to draw on
* @param p the picture to draw on
*/
public Turtle (Picture p) {
// let the parent constructor handle it
super(p);
}
/////////////////// methods ///////////////////////
//put your drawShape method here
public void drawShape(int size, Color color, int width) {
setPenWidth(width);
setPenColor(color);
int x=size*10;
forward(x);
turn(45);
forward(x);
turn(45);
forward(x);
turn(45);
forward(x);
turn(45);
forward(x);
turn(45);
forward(x);
turn(45);
forward(x);
turn(45);
forward(x);
}
public void drawStarPointShape(int sizetwo, int sizethree, Color color, int width) {
setPenWidth(width);
setPenColor(color);
int x=sizetwo*10;
int y=sizethree*45;
forward(x);
turn(y);
forward(x);
turn(y);
forward(x);
turn(y);
forward(x);
turn(y);
forward(x);
turn(y);
forward(x);
turn(y);
forward(x);
turn(y);
forward(x);
}
public void elaborateShape(Color color, int width) {
setPenWidth(width);
setPenColor(color);
forward(100);
turn(90);
forward(50);
turn(-135);
forward(71);
turn(-45);
forward(100);
turn(-45);
forward(71);
turn(-135);
forward(50);
turn(90);
forward(100);
turn(-90);
forward(100);
}
}