File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66 */
77public 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
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments