Skip to content

Commit d11dd8e

Browse files
committed
removed explicit this
1 parent bb437e3 commit d11dd8e

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

ch15/Cell.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,38 +34,38 @@ public Cell(int x, int y, int size) {
3434
* @param g graphics context
3535
*/
3636
public void draw(Graphics g) {
37-
g.setColor(this.color);
38-
g.fillRect(this.x + 1, this.y + 1, this.size - 1, this.size - 1);
37+
g.setColor(color);
38+
g.fillRect(x + 1, y + 1, size - 1, size - 1);
3939
g.setColor(Color.LIGHT_GRAY);
40-
g.drawRect(this.x, this.y, this.size, this.size);
40+
g.drawRect(x, y, size, size);
4141
}
4242

4343
/**
4444
* @return true if the color is OFF
4545
*/
4646
public boolean isOff() {
47-
return this.color == OFF;
47+
return color == OFF;
4848
}
4949

5050
/**
5151
* @return true if the color is ON
5252
*/
5353
public boolean isOn() {
54-
return this.color == ON;
54+
return color == ON;
5555
}
5656

5757
/**
5858
* Sets the cell's color to OFF.
5959
*/
6060
public void turnOff() {
61-
this.color = OFF;
61+
color = OFF;
6262
}
6363

6464
/**
6565
* Sets the cell's color to ON.
6666
*/
6767
public void turnOn() {
68-
this.color = ON;
68+
color = ON;
6969
}
7070

7171
}

ch15/GridCanvas.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ public class GridCanvas extends Canvas {
1919
public GridCanvas(int rows, int cols, int size) {
2020

2121
// build 2D array of cells
22-
this.array = new Cell[rows][cols];
22+
array = new Cell[rows][cols];
2323
for (int r = 0; r < rows; r++) {
2424
for (int c = 0; c < cols; c++) {
25-
this.array[r][c] = new Cell(c * size, r * size, size);
25+
array[r][c] = new Cell(c * size, r * size, size);
2626
}
2727
}
2828

0 commit comments

Comments
 (0)