Skip to content

Commit 8388e13

Browse files
committed
started Simple Bubble Quiz w/Jim
1 parent 88bbf42 commit 8388e13

File tree

4 files changed

+71
-71
lines changed

4 files changed

+71
-71
lines changed
0 Bytes
Binary file not shown.

TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/quizzes/graders/SimpleBubbleQuizAdapter.java

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,39 @@
11
package org.teachingkidsprogramming.recipes.quizzes.graders;
22

3+
import org.teachingextensions.logo.Tortoise;
4+
35
public class SimpleBubbleQuizAdapter
46
{
5-
public static class Pieces
7+
public int counter = 0;
8+
public void drawNextBase()
9+
{
10+
goToNextBase(100);
11+
drawDiamond(10);
12+
}
13+
public void goToNextBase(int size)
14+
{
15+
Tortoise.turn(-90);
16+
Tortoise.move(size);
17+
Tortoise.turn(-135);
18+
}
19+
public void drawDiamond(int size)
620
{
7-
public String beginning;
8-
public String middle;
9-
public String end;
21+
Tortoise.turn(45);
22+
Tortoise.move(size);
23+
Tortoise.turn(-90);
24+
Tortoise.move(size);
25+
Tortoise.turn(-90);
26+
Tortoise.move(size);
27+
Tortoise.turn(-90);
28+
Tortoise.move(size);
1029
}
11-
public String word1;
12-
public String word2;
13-
public String word3;
14-
public String template4;
15-
public void question1(String letter1, String letter3)
30+
public void question1()
1631
{
1732
}
1833
public void question2(String letter1)
1934
{
2035
}
21-
public void question3(String templateText, Object model)
36+
public void question3()
2237
{
2338
}
2439
public void question4(org.teachingkidsprogramming.recipes.quizzes.graders.AdLibsQuizAdapter.Pieces pieces)

TeachingKidsProgramming/src/org/teachingkidsprogramming/recipes/quizzes/graders/SimpleBubbleQuizGrader.java

Lines changed: 12 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import org.teachingextensions.logo.Colors;
99
import org.teachingextensions.logo.Paintable;
1010
import org.teachingextensions.logo.Tortoise;
11-
import org.teachingextensions.simpleparser.Parser;
1211
import org.teachingkidsprogramming.recipes.quizzes.graders.AdLibsQuizAdapter.Pieces;
1312

1413
public class SimpleBubbleQuizGrader implements Paintable
@@ -21,54 +20,48 @@ public Model(String three)
2120
this.three = three;
2221
}
2322
}
24-
private boolean[] answers;
23+
private boolean[] answers = new boolean[4];
2524
public static int TURTLE_SPEED = 9;
2625
private SimpleBubbleQuizAdapter quiz;
2726
private void displayScreen()
2827
{
2928
QuizUtils.prepareScoringScreen(answers, this, TURTLE_SPEED);
29+
Tortoise.show();
30+
Tortoise.setX(150);
31+
Tortoise.setY(200);
32+
Tortoise.setPenColor(Colors.Greens.GreenYellow);
33+
quiz.drawDiamond(100);
34+
quiz.question1();
35+
quiz.question3();
36+
/*for (int i = 1; i <= 4; i++)
37+
{
38+
drawNextBase();
39+
}*/
3040
}
3141
public void grade(SimpleBubbleQuizAdapter quiz)
3242
{
3343
this.quiz = quiz;
34-
answers = new boolean[]{grade1You(), grade2Won(), grade3The(), grade4Game()};
3544
displayScreen();
3645
}
3746
public void paint(Graphics2D g, JPanel caller)
3847
{
3948
QuizUtils.displayScores(g, 300, answers);
40-
Tortoise.hide();
4149
drawRewardShape(g);
4250
}
4351
public void drawRewardShape(Graphics2D g)
4452
{
45-
drawYou(g);
4653
drawWin(g);
47-
drawThe(g);
4854
drawGame(g);
4955
}
5056
private void drawGame(Graphics2D g)
5157
{
52-
quiz.template4 = "";
5358
Pieces pieces = new Pieces();
5459
quiz.question4(pieces);
5560
pieces.middle = "am";
56-
String word = Parser.parse(quiz.template4, pieces);
57-
drawWord(g, word, 0, 4, true);
58-
}
59-
private void drawThe(Graphics2D g)
60-
{
61-
quiz.word3 = "";
62-
Pieces model = new Pieces();
63-
model.middle = "H";
64-
quiz.question3("T{middle}E", model);
65-
drawWord(g, quiz.word3, 3, 2, false);
6661
}
6762
private void drawWin(Graphics2D g)
6863
{
69-
quiz.word2 = "WO";
7064
quiz.question2("n");
71-
drawWord(g, quiz.word2, 1, 0, false);
7265
}
7366
private void drawWord(Graphics2D g, String word, int x, int y, boolean horizontal)
7467
{
@@ -85,12 +78,6 @@ private int getPosition(int i)
8578
{
8679
return 100 + i * 53;
8780
}
88-
private void drawYou(Graphics2D g)
89-
{
90-
quiz.word1 = "NOT";
91-
quiz.question1("y", "u");
92-
drawWord(g, quiz.word1, 0, 1, true);
93-
}
9481
private void drawLetter(int x, int y, char c, Graphics2D g)
9582
{
9683
g.setColor(Colors.Browns.BurlyWood);
@@ -102,28 +89,4 @@ private void drawLetter(int x, int y, char c, Graphics2D g)
10289
int textX = x + (50 - charWidth) / 2;
10390
g.drawString("" + c, textX, textY);
10491
}
105-
private boolean grade1You()
106-
{
107-
quiz.word1 = "fake";
108-
quiz.question1("f", "o");
109-
return "foo".equals(quiz.word1);
110-
}
111-
private boolean grade2Won()
112-
{
113-
quiz.word2 = "passe";
114-
quiz.question2("d");
115-
return "passed".equals(quiz.word2);
116-
}
117-
private boolean grade3The()
118-
{
119-
quiz.word3 = "fake";
120-
quiz.question3("12{three}4", new Model("3"));
121-
return "1234".equals(quiz.word3);
122-
}
123-
private boolean grade4Game()
124-
{
125-
quiz.template4 = "fake";
126-
quiz.question4(new Pieces());
127-
return "g{middle}e".equals(quiz.template4);
128-
}
12992
}
Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,56 @@
11
package org.teachingkidsprogramming.section07events;
22

3+
import org.teachingextensions.logo.Tortoise;
4+
import org.teachingextensions.windows.MouseLeftClickListener;
5+
import org.teachingextensions.windows.MouseRightClickListener;
36
import org.teachingkidsprogramming.recipes.quizzes.graders.SimpleBubbleQuizAdapter;
47
import org.teachingkidsprogramming.recipes.quizzes.graders.SimpleBubbleQuizGrader;
58

69
public class SimpleBubbleQuiz extends SimpleBubbleQuizAdapter
10+
implements
11+
MouseLeftClickListener,
12+
MouseRightClickListener
713
{
814
//**THIS QUIZ IS IN PROGRESS
9-
// Grader could listen for events
10-
// students wire up events, then grader listens (draws)
11-
// student must click for final reward FAIL-> PASS (toggle)
12-
// Tortoise on baseball diamond - click on first base, second base
13-
// click order - change from fail to pass
14-
public void question1(String letter1, String letter3)
15+
public void question1()
1516
{
16-
//set current value of word1 to be letter1 + 'o' + letter3
17+
//code: wire up left click to draw first base
18+
Tortoise.getBackgroundWindow().addMouseLeftClickListener(this);
19+
//action: tortoise move to corner and draw a base
1720
}
1821
public void question2(String letter1)
1922
{
20-
//add the letter1 to the end of word2
23+
//code: add text 'You got a single' and then click on the first base
24+
//action: fail first in all case, draw base and pass after click
2125
}
22-
public void question3(String templateText, Object model)
26+
public void question3()
2327
{
24-
//use the parser to combine the template and the model as word3
28+
//wire up right click to get a home run
29+
Tortoise.getBackgroundWindow().addMouseRightClickListener(this);
30+
//so that when you click the Tortoise will move to home plate and draw it
2531
}
26-
public void question4(Pieces pieces)
32+
public void question4()
2733
{
28-
//set template4 to the template which does'g' + pieces.middle + 'e'
34+
//code: add text 'You got a home run' and then click on the home plate
35+
//action: fail first in all case, draw base and pass after click
2936
}
3037
public static void main(String[] args)
3138
{
3239
new SimpleBubbleQuizGrader().grade(new SimpleBubbleQuiz());
3340
}
41+
@Override
42+
public void onLeftMouseClick(int x, int y)
43+
{
44+
if (counter < 3)
45+
{
46+
drawNextBase();
47+
counter = counter + 1;
48+
}
49+
}
50+
@Override
51+
public void onRightMouseClick(int x, int y)
52+
{
53+
if (counter != 3) { return; }
54+
drawNextBase();
55+
}
3456
}

0 commit comments

Comments
 (0)