Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 543b43a

Browse filesBrowse files
committed
fixed invisible whack
1 parent c3eb035 commit 543b43a
Copy full SHA for 543b43a

File tree

Expand file treeCollapse file tree

2 files changed

+6
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+6
-6
lines changed
Open diff view settings
Collapse file

‎ch16/BlinkingPolygon.java‎

Copy file name to clipboardExpand all lines: ch16/BlinkingPolygon.java
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
public class BlinkingPolygon extends RegularPolygon {
88

9-
private boolean drawFlag;
9+
protected boolean visible;
1010
private int count;
1111

1212
/**
@@ -18,24 +18,24 @@ public class BlinkingPolygon extends RegularPolygon {
1818
*/
1919
public BlinkingPolygon(int nsides, int radius, Color color) {
2020
super(nsides, radius, color);
21-
drawFlag = true;
21+
visible = true;
2222
count = 0;
2323
}
2424

2525
@Override
2626
public void draw(Graphics g) {
27-
if (drawFlag) {
27+
if (visible) {
2828
super.draw(g);
2929
}
3030
}
3131

3232
@Override
3333
public void step() {
34-
// toggle drawFlag every 10 steps
34+
// toggle visibility every 10 steps
3535
count++;
3636
if (count == 10) {
3737
count = 0;
38-
drawFlag = !drawFlag;
38+
visible = !visible;
3939
}
4040
}
4141

Collapse file

‎ch16/Mole.java‎

Copy file name to clipboardExpand all lines: ch16/Mole.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void step() {
3434
*/
3535
public void whack() {
3636
// ignore whack when invisible
37-
if (color == BROWN) {
37+
if (visible) {
3838
color = Color.LIGHT_GRAY;
3939
alive = false;
4040
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.