Change the following game model into a GUI

白昼怎懂夜的黑 提交于 2021-01-29 12:38:06

问题


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

来源:https://stackoverflow.com/questions/65611235/change-the-following-game-model-into-a-gui

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!