Skip to content

Commit

Permalink
better use of const
Browse files Browse the repository at this point in the history
  • Loading branch information
montyr75 committed Jan 7, 2014
1 parent e59dcf3 commit 6369640
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions web/model/cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ class Cell extends Object with Observable {
}

class CellPoint {
int row;
int col;
final int row;
final int col;

CellPoint(int this.row, int this.col);
const CellPoint(int this.row, int this.col);

String toString() => "row: $row, col: $col";
}
18 changes: 9 additions & 9 deletions web/views/main/main_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ class MainView extends PolymerElement {
int turnCount;

// win patterns
final List<List<CellPoint>> winPatterns = [
[new CellPoint(0, 0), new CellPoint(0, 1), new CellPoint(0, 2)], // row 1
[new CellPoint(1, 0), new CellPoint(1, 1), new CellPoint(1, 2)], // row 2
[new CellPoint(2, 0), new CellPoint(2, 1), new CellPoint(2, 2)], // row 3
[new CellPoint(0, 0), new CellPoint(1, 0), new CellPoint(2, 0)], // col 1
[new CellPoint(0, 1), new CellPoint(1, 1), new CellPoint(2, 1)], // col 2
[new CellPoint(0, 2), new CellPoint(1, 2), new CellPoint(2, 2)], // col 3
[new CellPoint(0, 0), new CellPoint(1, 1), new CellPoint(2, 2)], // diag 1
[new CellPoint(0, 2), new CellPoint(1, 1), new CellPoint(2, 0)] // diag 2
final List<List<CellPoint>> winPatterns = const [
const [const CellPoint(0, 0), const CellPoint(0, 1), const CellPoint(0, 2)], // row 1
const [const CellPoint(1, 0), const CellPoint(1, 1), const CellPoint(1, 2)], // row 2
const [const CellPoint(2, 0), const CellPoint(2, 1), const CellPoint(2, 2)], // row 3
const [const CellPoint(0, 0), const CellPoint(1, 0), const CellPoint(2, 0)], // col 1
const [const CellPoint(0, 1), const CellPoint(1, 1), const CellPoint(2, 1)], // col 2
const [const CellPoint(0, 2), const CellPoint(1, 2), const CellPoint(2, 2)], // col 3
const [const CellPoint(0, 0), const CellPoint(1, 1), const CellPoint(2, 2)], // diag 1
const [const CellPoint(0, 2), const CellPoint(1, 1), const CellPoint(2, 0)] // diag 2
];

// UI data
Expand Down

0 comments on commit 6369640

Please sign in to comment.