SHARE
TWEET

Untitled

a guest Nov 20th, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. class Coord
  7. {
  8. public:
  9.     Coord() {}
  10.  
  11.     Coord(int x, int y)
  12.     {
  13.         this->m_x = x;
  14.         this->m_y = y;
  15.     }
  16.  
  17.     int GetX() {return this->m_x;}
  18.  
  19.     int GetY() {return this->m_y;}
  20.  
  21.     void SetX(int x) { this->m_x = x;}
  22.  
  23.     void SetY(int y) { this->m_y = y;}
  24.  
  25. private:
  26.     int m_x;
  27.  
  28.     int m_y;
  29. };
  30.  
  31.  
  32. class Figure
  33. {
  34. public:
  35.     Figure()
  36.     {
  37.         this->m_figureCharacter = '-';
  38.         this->m_figureName = "Empty";
  39.     }
  40.  
  41.     Figure(string name, char figure)
  42.     {
  43.         this->m_figureCharacter = figure;
  44.         this->m_figureName = name;
  45.     }
  46.  
  47.     char GetFigureCharacter() { this->m_figureCharacter;}
  48.  
  49.     string GetFigureName() { this->m_figureName;}
  50.  
  51. private:
  52.     char m_figureCharacter;
  53.     string m_figureName;
  54. };
  55.  
  56. class Table
  57. {
  58. public:
  59.     Table()
  60.     {
  61.         Figure emptyFigure = Figure("test", '-');
  62.  
  63.         for(int i = 0; i < 8; i++)
  64.         {
  65.             for(int j = 0; j < 8; j++)
  66.             {
  67.                 this->m_table[i][j] = emptyFigure;
  68.                 cout << m_table[i][j].GetFigureName() << endl;
  69.             }
  70.         }
  71.     }
  72.  
  73.     Figure GetFigure(Coord coord) {return this->m_table[coord.GetX()][coord.GetY()];}
  74.  
  75.     void SetFigure(Coord coord, Figure figure) { this->m_table[coord.GetX()][coord.GetY()] = figure;}
  76.  
  77. private:
  78.     Figure m_table[8][8];
  79. };
  80.  
  81. int main()
  82. {
  83.     Table current = Table();
  84.  
  85.     //cout << current.GetFigure(Coord(1,3)).GetFigureName() << endl;
  86.  
  87.     return 0;
  88. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top