summaryrefslogtreecommitdiff
path: root/src/Model
diff options
context:
space:
mode:
Diffstat (limited to 'src/Model')
-rw-r--r--src/Model/Cell.cpp27
-rw-r--r--src/Model/Cell.hpp15
-rw-r--r--src/Model/Grid.cpp37
-rw-r--r--src/Model/Grid.hpp27
4 files changed, 104 insertions, 2 deletions
diff --git a/src/Model/Cell.cpp b/src/Model/Cell.cpp
index e69de29..24fc53c 100644
--- a/src/Model/Cell.cpp
+++ b/src/Model/Cell.cpp
@@ -0,0 +1,27 @@
+#include "Cell.hpp"
+
+// Constructors
+
+Cell::Cell()
+{
+ m_value = " ";
+}
+
+Cell::Cell(std::string value)
+{
+ m_value = value;
+}
+
+// Destructor
+
+Cell::~Cell()
+{
+}
+
+// Description
+
+void Cell::description()
+{
+ return m_value;
+}
+
diff --git a/src/Model/Cell.hpp b/src/Model/Cell.hpp
index 888c63c..7775bf5 100644
--- a/src/Model/Cell.hpp
+++ b/src/Model/Cell.hpp
@@ -1,17 +1,28 @@
#ifndef DEF_CELL
#define DEF_CELL
-/* Cell.cpp
+/* Cell.h
* Defines the class Cell
* A cell represents a cell in the grid
* Creators : krilius, manzerbredes
* Date : 29/04/2015 */
#include <iostream>
-#include <SFML/SFML.h>
+#include <string>
class Cell
{
+ private:
+ std::string m_value;
+
+ public:
+ Cell();
+ Cell(std::string value);
+ ~Cell();
+
+ // Describes the cell in a terminal
+ std::string description();
+
};
#endif
diff --git a/src/Model/Grid.cpp b/src/Model/Grid.cpp
index e69de29..94ef5d7 100644
--- a/src/Model/Grid.cpp
+++ b/src/Model/Grid.cpp
@@ -0,0 +1,37 @@
+#include "Grid.h"
+
+Grid::Grid(int size)
+{
+ m_table = std::vector<std::vector<Cell*>>(size);
+ for(int i = 0 ; i < size ; i++)
+ {
+ m_table[i] = std::vector<Cell*>(size);
+ for (int j = 0 ; j < size ; j++)
+ {
+ Cell * cell = new Cell();
+ m_table[i][j] = cell;
+ }
+ }
+}
+
+Grid::~Grid()
+{
+ for(int i = 0 ; i < m_table.size() ; i++)
+ {
+ for(int i = 0 ; j < m_table[i].size() ; j++)
+ delete m_table[i][j];
+ }
+}
+
+void Grid::description()
+{
+ for(int i = 0 ; i < m_table.size() ; i++)
+ {
+ for(int j = 0 ; j < m_table[i].size() ; i++)
+ {
+ std::cout << m_table[i][j]->description();
+ }
+ std::cout << std::endl;
+ }
+}
+
diff --git a/src/Model/Grid.hpp b/src/Model/Grid.hpp
index e69de29..a9c6c86 100644
--- a/src/Model/Grid.hpp
+++ b/src/Model/Grid.hpp
@@ -0,0 +1,27 @@
+#ifndef DEF_GRID
+#define DEF_GRID
+
+/* Grid.h
+ * Defines the class Grid
+ * A grid contains a table of cells the game will be set on
+ * Creators : krilius, manzerbredes
+ * Date : 29/04/2015 */
+
+#include <iostream>
+#include <vector>
+
+#include "Cell.hpp"
+
+class Grid
+{
+ private:
+ std::vector<std::vector<Cell*>> m_table;
+
+ public:
+ Grid(int size);
+ ~Grid();
+ void description();
+};
+
+#endif
+