Skip to content

Commit c215058

Browse files
committed
tidy up Ch15
1 parent 76a6ee2 commit c215058

3 files changed

Lines changed: 23 additions & 6 deletions

File tree

ch15/Cell.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
/**
55
* A square at a fixed location that changes color.
6+
*
7+
* @author Chris Mayfield
8+
* @version 7.1.0
69
*/
710
public class Cell {
811

@@ -40,28 +43,32 @@ public void draw(Graphics g) {
4043
}
4144

4245
/**
43-
* @return true if the cell is OFF
46+
* Tests whether the cell is off.
47+
*
48+
* @return true if the cell is off
4449
*/
4550
public boolean isOff() {
4651
return state == 0;
4752
}
4853

4954
/**
50-
* @return true if the cell is ON
55+
* Tests whether the cell is on.
56+
*
57+
* @return true if the cell is on
5158
*/
5259
public boolean isOn() {
5360
return state == 1;
5461
}
5562

5663
/**
57-
* Sets the cell's state to OFF.
64+
* Sets the cell's state to off.
5865
*/
5966
public void turnOff() {
6067
state = 0;
6168
}
6269

6370
/**
64-
* Sets the cell's state to ON.
71+
* Sets the cell's state to on.
6572
*/
6673
public void turnOn() {
6774
state = 1;

ch15/Conway.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
/**
44
* Conway's Game of Life.
5+
*
6+
* @author Chris Mayfield
7+
* @version 7.1.0
58
*/
69
public class Conway {
710

@@ -109,8 +112,6 @@ public void update() {
109112

110113
/**
111114
* The simulation loop.
112-
*
113-
* @param rate frames per second
114115
*/
115116
private void mainloop() {
116117
while (true) {

ch15/GridCanvas.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
/**
55
* 2D array of cells representing a rectangular grid.
6+
*
7+
* @author Chris Mayfield
8+
* @version 7.1.0
69
*/
710
public class GridCanvas extends Canvas {
811

@@ -33,20 +36,26 @@ public GridCanvas(int rows, int cols, int size) {
3336
}
3437

3538
/**
39+
* Gets the number of rows.
40+
*
3641
* @return number of rows
3742
*/
3843
public int numRows() {
3944
return array.length;
4045
}
4146

4247
/**
48+
* Gets the number of columns.
49+
*
4350
* @return number of columns
4451
*/
4552
public int numCols() {
4653
return array[0].length;
4754
}
4855

4956
/**
57+
* Gets the cell at index (r, c).
58+
*
5059
* @param r row index
5160
* @param c column index
5261
* @return the cell

0 commit comments

Comments
 (0)