Skip to content

Commit 29362d5

Browse files
committed
Working on TortoiseMaze w/ @samanthalangit
1 parent dc3ec2a commit 29362d5

2 files changed

Lines changed: 28 additions & 10 deletions

File tree

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

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package org.teachingkidsprogramming.recipes.completed.section08events;
22

3-
import org.teachingextensions.logo.Tortoise;
4-
import org.teachingextensions.logo.utils.ColorUtils.PenColors;
5-
6-
import javax.swing.*;
73
import java.awt.event.ActionEvent;
84
import java.awt.event.ActionListener;
95

6+
import javax.swing.ImageIcon;
7+
import javax.swing.JButton;
8+
9+
import org.teachingextensions.logo.Tortoise;
10+
import org.teachingextensions.logo.utils.ColorUtils.PenColors;
11+
1012
//***********************ANSWER: In Progress***************************//
1113
// Need to write English comments and copy to STUDENT section //
1214
//
@@ -22,18 +24,26 @@ public TortoiseMaze()
2224
Tortoise.setSpeed(10);
2325
Tortoise.setPenColor(PenColors.Greens.Green);
2426
Tortoise.setPenWidth(4);
27+
// add image icons
2528
ImageIcon leftArrow = new ImageIcon(
2629
"../TeachingKidsProgramming.Source.Java/src/main/resources/icons/arrow-left.png");
27-
JButton leftButton = new JButton(leftArrow);
28-
Tortoise.getBackgroundWindow().addButton(leftButton);
2930
ImageIcon upArrow = new ImageIcon(
3031
"../TeachingKidsProgramming.Source.Java/src/main/resources/icons/arrow-up.png");
31-
JButton upButton = new JButton(upArrow);
32-
Tortoise.getBackgroundWindow().addButton(upButton);
32+
ImageIcon downArrow = new ImageIcon(
33+
"../TeachingKidsProgramming.Source.Java/src/main/resources/icons/arrow-down.png");
3334
ImageIcon rightArrow = new ImageIcon(
3435
"../TeachingKidsProgramming.Source.Java/src/main/resources/icons/arrow-right.png");
36+
// add buttons using icons
37+
JButton leftButton = new JButton(leftArrow);
38+
JButton upButton = new JButton(upArrow);
39+
JButton downButton = new JButton(downArrow);
3540
JButton rightButton = new JButton(rightArrow);
41+
// add buttons to your window
42+
Tortoise.getBackgroundWindow().addButton(leftButton);
43+
Tortoise.getBackgroundWindow().addButton(upButton);
44+
Tortoise.getBackgroundWindow().addButton(downButton);
3645
Tortoise.getBackgroundWindow().addButton(rightButton);
46+
// add actions to your buttons
3747
rightButton.addActionListener(new ActionListener()
3848
{
3949
@Override
@@ -55,7 +65,15 @@ public void actionPerformed(ActionEvent e)
5565
@Override
5666
public void actionPerformed(ActionEvent e)
5767
{
58-
Tortoise.move(25);
68+
Tortoise.move(35);
69+
}
70+
});
71+
downButton.addActionListener(new ActionListener()
72+
{
73+
@Override
74+
public void actionPerformed(ActionEvent e)
75+
{
76+
Tortoise.move(-35);
5977
}
6078
});
6179
Tortoise.setVisible(true);

src/main/java/org/teachingkidsprogramming/section06modelviewcontroller/OneFishTwoFish.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ private static void tellAStory(final String input)
2222
// Use 'fish' as the base text w/your scanner [story] HINT: useDelimeter --#5
2323
// Get the next number to use in your scanner [story] HINT: nextInt --#7
2424
// Get the next value to use in your scanner [story] HINT: next --#9
25-
// Iterate over each fish [string] HINT: Interable --#10
25+
// Iterate over each fish [string] HINT: Iterable --#10
2626
// Create a new string iterator --#11
2727
// Create a new scanner for your input --#12
2828
// Use a comma to separate the strings in your story HINT: useDelimeter --#13

0 commit comments

Comments
 (0)