Skip to content
Snippets Groups Projects
Commit 81aed3a4 authored by steyer's avatar steyer
Browse files

Új GameModel construtor GameBoard-dal

parent 77c8aec7
No related branches found
No related tags found
No related merge requests found
...@@ -4,25 +4,32 @@ import javax.swing.table.AbstractTableModel; ...@@ -4,25 +4,32 @@ import javax.swing.table.AbstractTableModel;
public class GameModel extends AbstractTableModel { public class GameModel extends AbstractTableModel {
private GameBoard cells; private GameBoard board;
private GameRunner runner; private GameRunner runner;
private GameRunner2 runner2; //TODO runners private GameRunner2 runner2; //TODO runners
private boolean editable; private boolean editable;
public GameModel(int height, int width) { public GameModel(int height, int width) {
cells = new GameBoard(height, width); board = new GameBoard(height, width);
runner = new GameRunner(this, cells); runner = new GameRunner(this, board);
runner2 = new GameRunner2(this, cells); runner2 = new GameRunner2(this, board);
runner2.start();
editable = true;
}
public GameModel(GameBoard board){
this.board = board;
runner2 = new GameRunner2(this, board);
runner2.start(); runner2.start();
editable = true; editable = true;
} }
public int getRowCount() { public int getRowCount() {
return cells.getHeight(); return board.getHeight();
} }
public int getColumnCount() { public int getColumnCount() {
return cells.getWidth(); return board.getWidth();
} }
public String getColumnName(int columnIndex) { public String getColumnName(int columnIndex) {
...@@ -53,7 +60,7 @@ public class GameModel extends AbstractTableModel { ...@@ -53,7 +60,7 @@ public class GameModel extends AbstractTableModel {
*/ */
//TODO runners //TODO runners
runner2.pauseRunner(); runner2.pauseRunner();
synchronized (cells) { synchronized (board) {
editable = true; editable = true;
} }
} }
...@@ -63,17 +70,17 @@ public class GameModel extends AbstractTableModel { ...@@ -63,17 +70,17 @@ public class GameModel extends AbstractTableModel {
} }
public Object getValueAt(int rowIndex, int columnIndex) { public Object getValueAt(int rowIndex, int columnIndex) {
return cells.get(rowIndex, columnIndex).isAlive(); return board.get(rowIndex, columnIndex).isAlive();
} }
public void setValueAt(Object aValue, int rowIndex, int columnIndex) { public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
cells.get(rowIndex, columnIndex).setAlive((boolean) aValue); board.get(rowIndex, columnIndex).setAlive((boolean) aValue);
} }
public void step() { public void step() {
//TODO törölni //TODO törölni
cells.step(); board.step();
fireTableDataChanged(); fireTableDataChanged();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment