Skip to content

Commit fd5ba4c

Browse files
committed
Comparison fix
1 parent 84d8be6 commit fd5ba4c

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/src/models/basic_shape.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,23 @@ abstract class BasicShape {
1111

1212
/// It's a getter that returns the grid.
1313
List<List<int>> get getGrid;
14+
15+
@override
16+
bool operator ==(Object other) {
17+
if (other is! BasicShape) {
18+
return false;
19+
}
20+
for (int i = 0; i < grid.length; i++) {
21+
for (int j = 0; j < grid[i].length; j++) {
22+
if (validatePosition(i, j)) {
23+
if (other.grid[i][j] != grid[i][j]) {
24+
return false;
25+
}
26+
}
27+
}
28+
}
29+
30+
return true;
31+
}
32+
1433
}

lib/src/models/cross.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Cross implements BasicShape {
4141
/// Overriding the `==` operator.
4242
@override
4343
bool operator ==(Object other) {
44-
if (other is! Cross) {
44+
if (other is! BasicShape) {
4545
return false;
4646
}
4747
for (int i = 0; i < grid.length; i++) {

0 commit comments

Comments
 (0)