Skip to content

Instantly share code, notes, and snippets.

@greg-hellings
Created July 12, 2018 20:02
Show Gist options
  • Save greg-hellings/d13443fbf496cb9f4307407321311433 to your computer and use it in GitHub Desktop.
Save greg-hellings/d13443fbf496cb9f4307407321311433 to your computer and use it in GitHub Desktop.
public class Base {
protected List<Cell> cells = new ArrayList<>();
protected Matrix matrix;
public Base(Matrix matrix) {
this.matrix = matrix;
for(int i = 0; i < matrix.dimension(); ++i)
// This call won't work, because Row.row isn't set until after the call to super(matrix);
this.cells.add(this.getCell(i));
}
public abstract Cell getCell(int i);
}
public class Row {
private int row;
public Row(int row, Matrix matrix) {
super(matrix);
this.row = row;
}
public Cell getCell(int i) {
return this.matrix.getCell(row, i);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment