public class Table extends java.lang.Object implements java.lang.Iterable<Table.Cell>, java.io.Serializable
Modifier and Type | Class and Description |
---|---|
static class |
Table.Cell
A cell in the enclosing table
|
(package private) class |
Table.CellIterator
An iterator over cells in this table.
|
Modifier and Type | Field and Description |
---|---|
(package private) Table.Cell[][] |
table |
Constructor and Description |
---|
Table()
Create a table with empty cells
|
Table(java.lang.String[] data)
Create a table with given data
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
Table.Cell |
getCell(int row,
int column)
Get cell of given row and column
|
java.util.List<Table.Cell> |
getEmptyCells()
Return a list with the empty cells in this table
|
char |
getLetter(int row,
int column)
Set a letter at a given row and column
|
java.util.List<Table.Cell> |
getNeighbors(Table.Cell cell)
The 8 neighboring cells of the given cell.
|
int |
hashCode() |
java.util.Iterator<Table.Cell> |
iterator() |
void |
setLetter(int row,
int column,
char letter)
Set a letter at a given row and column
|
java.lang.String |
toString() |
Table.Cell[][] table
public Table()
public Table(java.lang.String[] data)
data
- array of string to initialize tablepublic java.util.Iterator<Table.Cell> iterator()
iterator
in interface java.lang.Iterable<Table.Cell>
public char getLetter(int row, int column)
row
- to setcolumn
- to setpublic void setLetter(int row, int column, char letter)
row
- to setcolumn
- to setletter
- to setpublic java.util.List<Table.Cell> getEmptyCells()
public java.util.List<Table.Cell> getNeighbors(Table.Cell cell)
cell
- defining the neighborhoodTable.Cell
public Table.Cell getCell(int row, int column)
row
- of cellcolumn
- of cellpublic java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object