I'm currently working on creating a gui for a futoshiki game in java.
The default constructor for the game is as follows:
public Futoshiki() {
int row, col;
cells = new Cell[SETSIZE+1][SETSIZE+1];
for (row=1; row<=SETSIZE; row++)
for (col=1; col<=SETSIZE; col++)
cells[row][col] = new Cell(this, row, col);
// row constraints
rc = new Constraint[SETSIZE+1];
for (row=1; row<=SETSIZE; row++) {
rc[row] = new Constraint();
for (col=1; col<=SETSIZE; col++) {
rc[row].add(cells[row][col]);
cells[row][col].addConstraint(rc[row]);
}
}
// column constraints
cc = new Constraint[SETSIZE+1];
for (col=1; col<=SETSIZE; col++) {
cc[col] = new Constraint();
for (row=1; row<=SETSIZE; row++) {
cc[col].add(cells[row][col]);
cells[row][col].addConstraint(cc[col]);
}
}
// relations
rs = new Vector<Relation>();
}
This results in a 5x5 grid of cells for numbers, with additional
cells for relations in between each similar to below.
so far I've been able to create a 5x5 with the number cells using 2 classes - one class for the entire grid and another for the number cells.
I believe the constraints are there simply to implement the rules of the game.
I'm wondering can I create the additional relation cells using 2 classes I have or should I create another class for the relation cells?
If I do create another class my concern is trying to implement all the relation class functionality
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…