Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Life::askConfig() {
- /*
- Pre: Playing board is initialized
- Post: The playing board is configured, ready for playing
- */
- string rowInput; // Input for rows
- cin.ignore();
- int row, col; // Set all points on the grid to 0
- for (row = 0; row < maxrow_; row++)
- for (col = 0; col < maxcol_; col++)
- grid[row][col] = 0;
- cout << "Create your preferred playing board" << endl;
- cout << "input x for a live cell and leave a space for a dead one" << endl;
- for (int i = 0; i < maxrow_; i++) { // Ask the configuration of the playing board
- if (i < 9) {
- cout << "Row " << i + 1 << "? "; // Keeps the input levelled
- }
- else cout << "Row " << i + 1 << "? ";
- getline(cin, rowInput);
- for (unsigned int j = 0; j < rowInput.length(); j++) { // Puts the player's input into the grid
- if (rowInput[j] == 'x') {
- grid[i][j] = 1;
- }
- else grid[i][j] = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement