-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCell.java
More file actions
33 lines (27 loc) · 861 Bytes
/
Cell.java
File metadata and controls
33 lines (27 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* This file is requried to create a single cell or node in the maze.
This class holds the row and column information for each cell.
Cell.java
*/
public class Cell {
// Creates a constant row and column
public final int row, col;
// Constructor for Cell class
public Cell(int row, int col) {
this.row = row;
this.col = col;
}
// Determines wheter a 2 different cell obejects are equal
// Equality happens when rows and columns are the same
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (!(obj instanceof Cell)) return false;
Cell other = (Cell) obj;
return row == other.row && col == other.col;
}
// Creates a hash code based on cell row and column
@Override
public int hashCode() {
return row * 31 + col;
}
}