File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff 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++ ) {
You can’t perform that action at this time.
0 commit comments