Skip to content

Commit 1f0fc89

Browse files
committed
added API documentation
1 parent 6910bf0 commit 1f0fc89

3 files changed

Lines changed: 33 additions & 60 deletions

File tree

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
package org.teachingextensions.WindowUtils;
22

3+
import java.util.ArrayList;
4+
import java.util.List;
5+
36
import org.teachingextensions.logo.Turtle;
47
import org.teachingextensions.logo.utils.ColorUtils.PenColors;
58
import org.teachingextensions.logo.utils.InterfaceUtils.MultiTurtlePainter;
69
import org.teachingextensions.logo.utils.InterfaceUtils.MultiTurtleTrailPainter;
710
import org.teachingextensions.logo.utils.InterfaceUtils.TurtleFrame;
811
import org.teachingextensions.logo.utils.LineAndShapeUtils.Paintable;
912

10-
import java.util.ArrayList;
11-
import java.util.List;
12-
1313
/**
1414
* Use this window when you want to put more than one turtle on the same window
1515
*/
16-
public class MultiTurtleWindow extends TurtleWindow {
16+
public class MultiTurtleWindow extends TurtleWindow
17+
{
1718
private List<Turtle> turtles = new ArrayList<Turtle>();
18-
19-
public MultiTurtleWindow() {
19+
public MultiTurtleWindow()
20+
{
2021
super("Turtles, Turtles, Turtles!");
2122
this.setBackground(PenColors.Blues.DarkSlateBlue);
2223
}
23-
2424
/**
2525
* Adds a turtle instance to a window
2626
* NOTE: this method must be called BEFORE calling any other methods on turtle instances
@@ -29,52 +29,55 @@ public MultiTurtleWindow() {
2929
* @param turtle
3030
* A turtle instance
3131
*/
32-
public void addTurtle(Turtle turtle) {
33-
if (turtle == null) {
34-
return;
35-
}
32+
public void addTurtle(Turtle turtle)
33+
{
34+
if (turtle == null) { return; }
3635
turtle.setFrame(this.getFrame());
3736
turtle.setPanel(this);
38-
3937
this.turtles.add(turtle);
4038
clearPainters();
4139
configurePainters();
4240
}
43-
4441
@Override
45-
public TurtleWindow init(Turtle turtle, TurtleFrame frame) {
42+
public TurtleWindow init(Turtle turtle, TurtleFrame frame)
43+
{
4644
return this;
4745
}
48-
4946
@Override
50-
protected Paintable createTurtleTrailPainter() {
47+
protected Paintable createTurtleTrailPainter()
48+
{
5149
this.setTrailPainter(new MultiTurtleTrailPainter(this.turtles));
5250
return this.getTrailPainter();
5351
}
54-
5552
@Override
56-
protected Paintable createTurtlePainter() {
53+
protected Paintable createTurtlePainter()
54+
{
5755
this.setTurtlePainter(new MultiTurtlePainter(this.turtles, this.getImage()));
5856
return this.getTurtlePainter();
5957
}
60-
61-
public int getTurtleCount() {
58+
/**
59+
* Gets a count of turtles for a window
60+
* <p><b>Example:</b> {@code multiTurtleWindow.getTurtlesCount()}</p>
61+
*
62+
*/
63+
public int getTurtleCount()
64+
{
6265
return this.turtles.size();
6366
}
64-
6567
/**
6668
* Adds a turtle instance to a window and shows it on the window
6769
* <p><b>Example:</b> {@code multiTurtleWindow.addAndShowTurtle(myTurtle)}</p>
6870
*
6971
* @param turtle
7072
* A turtle instance
7173
*/
72-
public void addAndShowTurtle(Turtle turtle) {
74+
public void addAndShowTurtle(Turtle turtle)
75+
{
7376
this.addTurtle(turtle);
7477
this.showTurtle(turtle);
7578
}
76-
77-
private void showTurtle(Turtle turtle) {
79+
private void showTurtle(Turtle turtle)
80+
{
7881
turtle.show();
7982
}
8083
}

src/main/java/org/teachingextensions/logo/Tortoise.java

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
package org.teachingextensions.logo;
22

3+
import java.awt.Color;
4+
35
import org.teachingextensions.WindowUtils.TurtleWindow;
46
import org.teachingextensions.logo.Turtle.Animals;
7+
import org.teachingextensions.logo.utils.TortoiseUtils;
58
import org.teachingextensions.logo.utils.ColorUtils.PenColors;
69
import org.teachingextensions.logo.utils.LineAndShapeUtils.Text;
710
import org.teachingextensions.logo.utils.PizzaUtils.Pizza;
811
import org.teachingextensions.logo.utils.PizzaUtils.Topping;
9-
import org.teachingextensions.logo.utils.TortoiseUtils;
1012
import org.teachingextensions.virtualproctor.VirtualProctor;
1113

12-
import java.awt.*;
13-
1414
/**
1515
* <img src="https://lh5.googleusercontent.com/-B3Q59gpYW8o/T4tA2k_TYUI/AAAAAAAAAjo/WiqdoXjbkb0/s65/Tortoise.png" style="text-align: left" alt="A tortoise drawing a line" >
1616
* The Tortoise allows you to draw lines and shapes by moving it around on the window
1717
*/
1818
public class Tortoise
1919
{
2020
private Topping topping;
21-
2221
/**
2322
* Displays the Tortoise
2423
* <div><b>Example:</b> {@code Tortoise.show()} </div>
@@ -27,7 +26,6 @@ public static void show()
2726
{
2827
turtle().show();
2928
}
30-
3129
/**
3230
* Gets the speed that the tortoise moves
3331
* <div><b>Example:</b> {@code int speed = Tortoise.getSpeed(8);}</div>
@@ -38,7 +36,6 @@ public static int getSpeed()
3836
{
3937
return turtle().getSpeed();
4038
}
41-
4239
/**
4340
* Sets the speed the tortoise moves
4441
* <div><b>Example:</b> {@code Tortoise.setSpeed(8)}</div>
@@ -50,7 +47,6 @@ public static void setSpeed(int speed)
5047
{
5148
turtle().setSpeed(speed);
5249
}
53-
5450
/**
5551
* Moves the Tortoise Forward the number of pixels specified. <br>
5652
* <div><b>Example:</b> {@code Tortoise.move(72)}</div>
@@ -75,7 +71,6 @@ public static void turn(Number degreesToTheRight)
7571
{
7672
turtle().turn(degreesToTheRight.doubleValue());
7773
}
78-
7974
/**
8075
* Gives you access to the window the
8176
* Tortoise is moving on so you can do things like change it's color. <br>
@@ -86,7 +81,6 @@ public static TurtleWindow getBackgroundWindow()
8681
{
8782
return turtle().getBackgroundWindow();
8883
}
89-
9084
/**
9185
* Gets the current width of the pen drawn by the Tortoise. <br>
9286
* <div><b>Example:</b> {@code width = Tortoise.getPenWidth()}</div>
@@ -97,7 +91,6 @@ public static int getPenWidth()
9791
{
9892
return turtle().getPenWidth();
9993
}
100-
10194
/**
10295
* Sets the width of the pen drawn by the Tortoise. <br>
10396
* <div><b>Example:</b> {@code Tortoise.setPenWidth(2)}</div>
@@ -109,7 +102,6 @@ public static void setPenWidth(Number width)
109102
{
110103
turtle().setPenWidth(width.intValue());
111104
}
112-
113105
/**
114106
* Gets the current color of the pen drawn by the Tortoise. <br>
115107
* <div><b>Example:</b> {@code pen = Tortoise.getPenColor()}</div>
@@ -120,20 +112,18 @@ public static Color getPenColor()
120112
{
121113
return turtle().getPenColor();
122114
}
123-
124115
/**
125-
* Sets the color drawn by the Tortoise. <br>
116+
* Sets the color of the line drawn by the Tortoise. <br>
126117
* <div><b>Example:</b> {@code Tortoise.setPenColor(PenColors.Reds.Red)}</div>
127118
*
128119
* @param color
129-
* the color of the pen
120+
* the color of the line drawn
130121
* @see PenColors
131122
*/
132123
public static void setPenColor(Color color)
133124
{
134125
turtle().setPenColor(color);
135126
}
136-
137127
/**
138128
* Gets the current position of the Tortoise on the y axis. <br>
139129
* (0,0) is the top left of the screen <br>
@@ -145,7 +135,6 @@ public static int getY()
145135
{
146136
return turtle().getY();
147137
}
148-
149138
/**
150139
* Sets the position of the Tortoise on the y axis. <br>
151140
* (0,0) is the top left of the screen <br>
@@ -158,7 +147,6 @@ public static void setY(int y)
158147
{
159148
turtle().setY(y);
160149
}
161-
162150
/**
163151
* Gets the current position of the Tortoise on the x axis. <br>
164152
* (0,0) is the top left of the screen <br>
@@ -170,7 +158,6 @@ public static int getX()
170158
{
171159
return turtle().getX();
172160
}
173-
174161
/**
175162
* Sets the position of the Tortoise on the x axis. <br>
176163
* (0,0) is the top left of the screen <br>
@@ -183,7 +170,6 @@ public static void setX(int x)
183170
{
184171
turtle().setX(x);
185172
}
186-
187173
/**
188174
* Gets the current heading of the Tortoise. <br>
189175
* 0 degrees is due north. <br>
@@ -196,7 +182,6 @@ public static double getAngle()
196182
{
197183
return turtle().getAngleInDegrees();
198184
}
199-
200185
/**
201186
* Sets the angle the Tortoise is facing. <br>
202187
* 0 is straight up (like 'North') <br>
@@ -209,7 +194,6 @@ public static void setAngle(int angle)
209194
{
210195
turtle().setAngleInDegrees(angle);
211196
}
212-
213197
/**
214198
* Changes the type of animal you are using. <br>
215199
* <div><b>Example:</b> {@code Tortoise.setAnimal(Animals.Spider);}</div>
@@ -221,7 +205,6 @@ public static void setAnimal(Animals animal)
221205
{
222206
turtle().setAnimal(animal);
223207
}
224-
225208
/**
226209
* Blows up your turtle! <br>
227210
* <div><b>Example:</b> {@code Tortoise.explode(Animals.ExplodedTurtle);}</div>
@@ -232,7 +215,6 @@ public static void explode()
232215
{
233216
turtle().setAnimal(Animals.ExplodedTurtle);
234217
}
235-
236218
/**
237219
* Makes it so the tortoise will not draw a line of color out of its butt. <br>
238220
* <b>Example:</b> {@code Tortoise.penUp()}
@@ -241,7 +223,6 @@ public static void setPenUp()
241223
{
242224
turtle().penUp();
243225
}
244-
245226
/**
246227
* Makes it so a line of color out of will trail from the Tortoise. <br>
247228
* <b>Example:</b> {@code Tortoise.penDown()}
@@ -250,7 +231,6 @@ public static void setPenDown()
250231
{
251232
turtle().penDown();
252233
}
253-
254234
/**
255235
* Removes everything from the window. <br>
256236
* <b>Example:</b> {@code Tortoise.clearWindow()}
@@ -260,7 +240,6 @@ public static void clear()
260240
turtle().clear();
261241
turtle().getBackgroundWindow().setTurtle(turtle());
262242
}
263-
264243
/**
265244
* Hides the tortoise, you will still see the pen markings it made before and after it's hidden. <br>
266245
* <b>Example:</b> {@code Tortoise.hide()}
@@ -269,12 +248,10 @@ public static void hide()
269248
{
270249
turtle().hide();
271250
}
272-
273251
private static Turtle turtle()
274252
{
275253
return TortoiseUtils.getTurtle();
276254
}
277-
278255
/**
279256
* Moves the Tortoise to a particular spot on the canvas. <br>
280257
* <div><b>Example:</b> {@code Tortoise.moveTo(100,200);}</div>
@@ -288,12 +265,10 @@ public static void moveTo(int x, int y)
288265
{
289266
turtle().moveTo(x, y);
290267
}
291-
292268
public static TurtleWindow ___()
293269
{
294270
return new TurtleWindow();
295271
}
296-
297272
/**
298273
* Makes a cool shape fast
299274
* <div><b>Example: </b> {@code tortoise.drawShape(6,PenColors.Reds.Red, 50, 20)}</div>
@@ -322,7 +297,6 @@ public static void drawShape(int sides, Color color, int length, int width)
322297
VirtualProctor.setClassName("Grace Hopper's Class");
323298
VirtualProctor.setName("Jean Bartik");
324299
}
325-
326300
/**
327301
* Draws an entire Tortoise -- fast!
328302
* <div><b>Example: </b> {@code tortoise.drawTortoise()}</div>
@@ -344,7 +318,6 @@ public static void drawTortoise()
344318
Tortoise.turn(-90);
345319
Tortoise.makeTortoiseLeg();
346320
}
347-
348321
private static void makeTortoiseLeg()
349322
{
350323
for (int i = 0; i < 4; i++)
@@ -353,7 +326,6 @@ private static void makeTortoiseLeg()
353326
Tortoise.turn(90);
354327
}
355328
}
356-
357329
private static void makeTortoiseBody()
358330
{
359331
Tortoise.turn(-90);
@@ -375,13 +347,11 @@ private static void makeTortoiseBody()
375347
Tortoise.turn(-25);
376348
Tortoise.move(65);
377349
}
378-
379350
public static void setVisible(boolean b)
380351
{
381352
turtle().setFrameVisible(b);
382353
turtle().setPanelVisible(b);
383354
}
384-
385355
/**
386356
* Checks if a tortoise can eat a slice of a pizza
387357
* <div><b>Example:</b> {@code tortoise.eatPizza(pizza)}</div>
@@ -397,7 +367,6 @@ public boolean eatPizza(Pizza pizza)
397367
if (this.topping != Topping.Cheese) { return pizza.hasTopping(topping); }
398368
return pizza.wasCooked() && pizza.hasTopping(topping);
399369
}
400-
401370
/**
402371
* Checks to see if a tortoise likes a particular kind of pizza topping
403372
* <div><b>Example:</b> {@code tortoise.likesTopping(topping)}</div>

src/main/java/org/teachingkidsprogramming/recipes/completed/section08events/DeepDive08Events.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public void twoCirclesAgain() throws Exception
3939
// shows use of different type of properties
4040
Assert.assertEquals(c2, result);
4141
}
42+
@SuppressWarnings("unused")
4243
@Test
4344
public void twoCirclesYetAgain() throws Exception
4445
{

0 commit comments

Comments
 (0)