Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
129 views
in Technique[技术] by (71.8m points)

java - Change the following game model into a GUI

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. 5x5 futoshiki

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...