Advertisement
Guest User

Untitled

a guest
Oct 21st, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. #include "Table.hpp"
  2. #include <iostream>
  3.  
  4. //Table:: n=7;
  5. //char** board = new char*[n];
  6.  
  7. int Table::getN() {
  8. return this->n;
  9. }
  10. void Table::setN(int n) {
  11. this->n = n;
  12. }
  13. char** Table::getBoard() {
  14. return this->board;
  15. }
  16. void Table::setBoard(char** board) {
  17. this->board = board;
  18. }
  19. void Table::createBoard(int n) {
  20. for (int i = 0; i < n; i++)
  21. this->board[i] = new char[n];
  22. }
  23. void Table::changeSize(int k) {
  24. char** temp = new char*[k];
  25. for (int i = 0; i < k; i++)
  26. temp[i] = new char[k];
  27. for (int i = 0; i < this->n; i++)
  28. for (int j = 0; j < this->n; j++)
  29. temp[i][j] = this->board[i][j];
  30. delete[] this->board;
  31. this->board = temp;
  32. this->n = k;
  33. //delete[] temp;
  34. }
  35. void Table::fillCells() {
  36. int k = this->n;
  37. for (int i = 0; i < k; i++)
  38. for (int j = 0; j < k; j++)
  39. this->board[i][j] = 'x';
  40. }
  41. void Table::printBoard() {
  42. int k = this->n;
  43. for (int i = 0; i < k; i++) {
  44. for (int j = 0; j < k; j++)
  45. std::cout << this->board[i][j];
  46. std::cout << "\n";
  47. }
  48. //std::cout << this->board[6][6];
  49. }
  50. void Table::destroyBoard() {
  51. delete[] this->board;
  52.  
  53. }
  54. Table::Table(int n) {
  55. this->n = n;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement