#include "VierGewinntModel.h" VierGewinntModel::VierGewinntModel(int r, int c) { rows = r; cols = c; spielfeld = new char[rows*cols]; initGame(); } VierGewinntModel::~VierGewinntModel(void) { delete [] (spielfeld); } bool VierGewinntModel::insertCoin(int col, char c) { bool rc = false; if ( col < 0 || col > cols-1) return rc; for (int i=rows-1; i>=0; i--) { if ( *(spielfeld + (rows*col + i)) == EMPTY ) { *(spielfeld+ (rows*col + i)) = c; rc = true; break; } } return rc; } char VierGewinntModel::getPosition(int row, int col) { if ( col < 0 || col > cols-1) return NULL; if ( row < 0 || row > rows-1) return NULL; return *(spielfeld + (rows*col + row)); } bool VierGewinntModel::checkRowWin(int p) { bool rc = false; char tmp; if ( p == 1 ) tmp = COIN1; else tmp = COIN2; for (int row=0; row