Skip to content

Commit 4889d7d

Browse files
committed
Cleanup warnings
1 parent d535705 commit 4889d7d

File tree

19 files changed

+482
-173
lines changed

19 files changed

+482
-173
lines changed

.settings/org.eclipse.jdt.core.prefs

Lines changed: 284 additions & 0 deletions
Large diffs are not rendered by default.

.settings/org.eclipse.jdt.ui.prefs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
eclipse.preferences.version=1
2+
formatter_profile=_Spun
3+
formatter_settings_version=12

src/main/java/org/teachingkidsprogramming/recipes/quizzes/graders/AdLibsQuizGrader.java

Lines changed: 116 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -12,118 +12,120 @@
1212
import org.teachingkidsprogramming.recipes.quizzes.graders.AdLibsQuizAdapter.Pieces;
1313

1414
public class AdLibsQuizGrader implements Paintable {
15-
private static class Model {
16-
public String three;
17-
18-
public Model(String three) {
19-
this.three = three;
20-
}
21-
}
22-
23-
private boolean[] answers;
24-
public static int TURTLE_SPEED = 9;
25-
private AdLibsQuizAdapter quiz;
26-
27-
private void displayScreen() {
28-
QuizUtils.prepareScoringScreen(answers, this, TURTLE_SPEED);
29-
}
30-
31-
public void grade(AdLibsQuizAdapter quiz) {
32-
this.quiz = quiz;
33-
answers = new boolean[] { grade1You(), grade2Won(), grade3The(),
34-
grade4Game() };
35-
displayScreen();
36-
}
37-
38-
public void paint(Graphics2D g, JPanel caller) {
39-
QuizUtils.displayScores(g, 300, answers);
40-
Tortoise.hide();
41-
drawRewardShape(g);
42-
}
43-
44-
public void drawRewardShape(Graphics2D g) {
45-
drawYou(g);
46-
drawWin(g);
47-
drawThe(g);
48-
drawGame(g);
49-
}
50-
51-
private void drawGame(Graphics2D g) {
52-
quiz.template4 = "";
53-
Pieces pieces = new Pieces();
54-
quiz.question4(pieces);
55-
pieces.middle = "am";
56-
String word = Parser.parse(quiz.template4, pieces);
57-
drawWord(g, word, 0, 4, true);
58-
}
59-
60-
private void drawThe(Graphics2D g) {
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);
66-
}
67-
68-
private void drawWin(Graphics2D g) {
69-
quiz.word2 = "WO";
70-
quiz.question2("n");
71-
drawWord(g, quiz.word2, 1, 0, false);
72-
}
73-
74-
private void drawWord(Graphics2D g, String word, int x, int y,
75-
boolean horizontal) {
76-
char[] letters = word.toUpperCase().toCharArray();
77-
int dx = horizontal ? 1 : 0;
78-
int dy = horizontal ? 0 : 1;
79-
for (int i = 0; i < letters.length; i++) {
80-
char c = letters[i];
81-
drawLetter(getPosition(x + dx * i), getPosition(y + dy * i), c, g);
82-
}
83-
}
84-
85-
private int getPosition(int i) {
86-
return 100 + i * 53;
87-
}
88-
89-
private void drawYou(Graphics2D g) {
90-
quiz.word1 = "NOT";
91-
quiz.question1("y", "u");
92-
drawWord(g, quiz.word1, 0, 1, true);
93-
}
94-
95-
private void drawLetter(int x, int y, char c, Graphics2D g) {
96-
g.setColor(PenColors.Browns.BurlyWood);
97-
g.drawRect(x, y, 50, 50);
98-
g.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 36));
99-
int charWidth = g.getFontMetrics().charWidth(c);
100-
int charHeight = g.getFontMetrics().getAscent();
101-
int textY = y + (40 - charHeight) / 2 + charHeight;
102-
int textX = x + (50 - charWidth) / 2;
103-
g.drawString("" + c, textX, textY);
104-
}
105-
106-
private boolean grade1You() {
107-
quiz.word1 = "fake";
108-
quiz.question1("f", "o");
109-
return "foo".equals(quiz.word1);
110-
}
111-
112-
private boolean grade2Won() {
113-
quiz.word2 = "passe";
114-
quiz.question2("d");
115-
return "passed".equals(quiz.word2);
116-
}
117-
118-
private boolean grade3The() {
119-
quiz.word3 = "fake";
120-
quiz.question3("12{three}4", new Model("3"));
121-
return "1234".equals(quiz.word3);
122-
}
123-
124-
private boolean grade4Game() {
125-
quiz.template4 = "fake";
126-
quiz.question4(new Pieces());
127-
return "g{middle}e".equals(quiz.template4);
128-
}
15+
private static class Model {
16+
@SuppressWarnings("unused")
17+
public String three;
18+
19+
public Model(String three) {
20+
this.three = three;
21+
}
22+
}
23+
24+
private boolean[] answers;
25+
public static int TURTLE_SPEED = 9;
26+
private AdLibsQuizAdapter quiz;
27+
28+
private void displayScreen() {
29+
QuizUtils.prepareScoringScreen(answers, this, TURTLE_SPEED);
30+
}
31+
32+
public void grade(AdLibsQuizAdapter quiz) {
33+
this.quiz = quiz;
34+
answers = new boolean[] { grade1You(), grade2Won(), grade3The(),
35+
grade4Game() };
36+
displayScreen();
37+
}
38+
39+
@Override
40+
public void paint(Graphics2D g, JPanel caller) {
41+
QuizUtils.displayScores(g, 300, answers);
42+
Tortoise.hide();
43+
drawRewardShape(g);
44+
}
45+
46+
public void drawRewardShape(Graphics2D g) {
47+
drawYou(g);
48+
drawWin(g);
49+
drawThe(g);
50+
drawGame(g);
51+
}
52+
53+
private void drawGame(Graphics2D g) {
54+
quiz.template4 = "";
55+
Pieces pieces = new Pieces();
56+
quiz.question4(pieces);
57+
pieces.middle = "am";
58+
String word = Parser.parse(quiz.template4, pieces);
59+
drawWord(g, word, 0, 4, true);
60+
}
61+
62+
private void drawThe(Graphics2D g) {
63+
quiz.word3 = "";
64+
Pieces model = new Pieces();
65+
model.middle = "H";
66+
quiz.question3("T{middle}E", model);
67+
drawWord(g, quiz.word3, 3, 2, false);
68+
}
69+
70+
private void drawWin(Graphics2D g) {
71+
quiz.word2 = "WO";
72+
quiz.question2("n");
73+
drawWord(g, quiz.word2, 1, 0, false);
74+
}
75+
76+
private void drawWord(Graphics2D g, String word, int x, int y,
77+
boolean horizontal) {
78+
char[] letters = word.toUpperCase().toCharArray();
79+
int dx = horizontal ? 1 : 0;
80+
int dy = horizontal ? 0 : 1;
81+
for (int i = 0; i < letters.length; i++) {
82+
char c = letters[i];
83+
drawLetter(getPosition(x + dx * i), getPosition(y + dy * i), c, g);
84+
}
85+
}
86+
87+
private int getPosition(int i) {
88+
return 100 + i * 53;
89+
}
90+
91+
private void drawYou(Graphics2D g) {
92+
quiz.word1 = "NOT";
93+
quiz.question1("y", "u");
94+
drawWord(g, quiz.word1, 0, 1, true);
95+
}
96+
97+
private void drawLetter(int x, int y, char c, Graphics2D g) {
98+
g.setColor(PenColors.Browns.BurlyWood);
99+
g.drawRect(x, y, 50, 50);
100+
g.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 36));
101+
int charWidth = g.getFontMetrics().charWidth(c);
102+
int charHeight = g.getFontMetrics().getAscent();
103+
int textY = y + (40 - charHeight) / 2 + charHeight;
104+
int textX = x + (50 - charWidth) / 2;
105+
g.drawString("" + c, textX, textY);
106+
}
107+
108+
private boolean grade1You() {
109+
quiz.word1 = "fake";
110+
quiz.question1("f", "o");
111+
return "foo".equals(quiz.word1);
112+
}
113+
114+
private boolean grade2Won() {
115+
quiz.word2 = "passe";
116+
quiz.question2("d");
117+
return "passed".equals(quiz.word2);
118+
}
119+
120+
private boolean grade3The() {
121+
quiz.word3 = "fake";
122+
quiz.question3("12{three}4", new Model("3"));
123+
return "1234".equals(quiz.word3);
124+
}
125+
126+
private boolean grade4Game() {
127+
quiz.template4 = "fake";
128+
quiz.question4(new Pieces());
129+
return "g{middle}e".equals(quiz.template4);
130+
}
129131
}

src/main/java/org/teachingkidsprogramming/section02methods/DeepDive02Variables.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.junit.Test;
66

77
@Ignore
8+
@SuppressWarnings("unused")
89
public class DeepDive02Variables
910
{
1011
// How to do deep dive:

src/main/java/org/teachingkidsprogramming/section02methods/TriangleShell.java

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
package org.teachingkidsprogramming.section02methods;
22

3-
public class TriangleShell
4-
{
3+
@SuppressWarnings("unused")
4+
public class TriangleShell {
55
private static int length;
6-
public static void main(String[] args)
7-
{
8-
// Show the tortoise --#1
9-
// Make the tortoise go as fast as possible --#6
10-
// Do the following 60 times --#7.1
11-
// Change the pen color of the line the tortoise draws to a random color --#9
12-
// Increase the current length of the side by 4 pixels --#8
6+
7+
public static void main(String[] args) {
8+
// Show the tortoise --#1
9+
// Make the tortoise go as fast as possible --#6
10+
// Do the following 60 times --#7.1
11+
// Change the pen color of the line the tortoise draws to a random color
12+
// --#9
13+
// Increase the current length of the side by 4 pixels --#8
1314
//
14-
// drawTriangle (recipe below) --#5.1
15-
// ------------- Recipe for drawTriangle --#5.2
16-
// Do the following 3 times --#3.1
17-
// Move the tortoise the current length of a side --#4
18-
// Turn the tortoise 1/3rd of 360 degrees --#2
19-
// Repeat --#3.2
20-
// ------------- End of drawTriangle recipe --#5.3
15+
// drawTriangle (recipe below) --#5.1
16+
// ------------- Recipe for drawTriangle --#5.2
17+
// Do the following 3 times --#3.1
18+
// Move the tortoise the current length of a side --#4
19+
// Turn the tortoise 1/3rd of 360 degrees --#2
20+
// Repeat --#3.2
21+
// ------------- End of drawTriangle recipe --#5.3
2122
//
22-
// Turn the tortoise 1/60th of 360 degrees to the right --#10
23-
// Repeat --#7.2
23+
// Turn the tortoise 1/60th of 360 degrees to the right --#10
24+
// Repeat --#7.2
2425
}
2526
// Related Videos:
2627
// Sub recipe-> Method : http://youtu.be/C6fnqjceVcs

src/main/java/org/teachingkidsprogramming/section03ifs/DeepDive03Ifs.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.junit.Test;
66

77
@Ignore
8+
@SuppressWarnings("unused")
89
public class DeepDive03Ifs
910
{
1011
// How to do deep dive:

src/main/java/org/teachingkidsprogramming/section05recursion/TurtleTree.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
public class TurtleTree
77
{
8+
@SuppressWarnings("unused")
89
public static void main(String[] args)
910
{
1011
// Make the tortoise go as fast as possible --#10

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.junit.Test;
99
import org.teachingextensions.logo.Tortoise;
1010

11+
@SuppressWarnings("unused")
1112
public class DeepDive06ModelViewController
1213
{
1314
// How to do deep dive:

src/main/java/org/teachingkidsprogramming/section07events/DeepDive07Events.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.teachingextensions.logo.Turtle;
1111
import org.teachingextensions.logo.Turtle.Animals;
1212

13+
@SuppressWarnings("unused")
1314
public class DeepDive07Events
1415
{
1516
// How to do deep dive:

src/main/java/org/teachingkidsprogramming/section08tdd/DeepDive08TDD.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.teachingextensions.logo.Tortoise;
88

99
//This deepdive is in progress!
10+
@SuppressWarnings("unused")
1011
public class DeepDive08TDD
1112
{
1213
// How to do deep dive:

0 commit comments

Comments
 (0)