void Playfield::generatePlayfield( void ) { enum CellType { CELL_TYPE_FREE, CELL_TYPE_OCCUPIED, CELL_TYPE_MAX = CELL_TYPE_OCCUPIED }; RandomNumberGenerator randomNumberGenerator; for( int y = 0; y < this->height; y ++ ) { for( int x = 0; x < this->width; x ++ ) { CellType cellType = static_cast<CellType> ( randomNumberGenerator.generate( CELL_TYPE_MAX ) ); if( cellType == CELL_TYPE_FREE ) { this->playfield[ y ][ x ] = new FreeCell( this->imageProvider, Position( y, x ) ); } else { // cellType == CELL_TYPE_OCCUPIED this->playfield[ y ][ x ] = new OccupiedCell( this->imageProvider, Position( y, x ) ); } } } }