Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. void Life::askConfig() {
  2. /*
  3. Pre: Playing board is initialized
  4. Post: The playing board is configured, ready for playing
  5. */
  6.  
  7.  
  8. string rowInput; // Input for rows
  9. cin.ignore();
  10.  
  11. int row, col; // Set all points on the grid to 0
  12. for (row = 0; row < maxrow_; row++)
  13. for (col = 0; col < maxcol_; col++)
  14. grid[row][col] = 0;
  15.  
  16. cout << "Create your preferred playing board" << endl;
  17. cout << "input x for a live cell and leave a space for a dead one" << endl;
  18. for (int i = 0; i < maxrow_; i++) { // Ask the configuration of the playing board
  19. if (i < 9) {
  20. cout << "Row " << i + 1 << "? "; // Keeps the input levelled
  21. }
  22. else cout << "Row " << i + 1 << "? ";
  23.  
  24. getline(cin, rowInput);
  25.  
  26. for (unsigned int j = 0; j < rowInput.length(); j++) { // Puts the player's input into the grid
  27. if (rowInput[j] == 'x') {
  28. grid[i][j] = 1;
  29. }
  30. else grid[i][j] = 0;
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement