17 |
* Free Software Foundation, Inc., * |
* Free Software Foundation, Inc., * |
18 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 |
***************************************************************************/ |
***************************************************************************/ |
20 |
#ifndef SOLUTION_H |
#ifndef SOLUTIONINT_H |
21 |
#define SOLUTION_H |
#define SOLUTIONINT_H |
22 |
|
|
23 |
|
//#include <solution.h> |
24 |
#include "config.h" |
#include "config.h" |
25 |
|
|
26 |
/** |
class Solution |
|
@author Torben Nielsen |
|
|
*/ |
|
|
class Solution |
|
27 |
{ |
{ |
28 |
public: |
public: |
29 |
|
Solution(int size); |
30 |
|
|
31 |
|
~Solution(); |
32 |
|
|
33 |
// functions |
//bool getMatrix(int x, int y); |
34 |
Solution(int size=8); |
bool getMatrix(int x, int y) { |
35 |
Solution(const Solution &input); |
return (m_matrix[x] == y); |
36 |
~Solution(); |
} |
37 |
|
|
38 |
void set(bool input[MAX_SIZE][MAX_SIZE]); |
|
39 |
void rotate90(); |
//void setMatrix(int x, int y, bool val); |
40 |
void mirror(); |
void setMatrix(int x, int y, bool val) { |
41 |
|
if (val == true) |
42 |
Solution* copy(); |
m_matrix[x] = y; |
43 |
|
else |
44 |
|
m_matrix[x] = -1; |
45 |
|
} |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
bool operator ==(const Solution& sol); |
50 |
|
|
51 |
|
Solution* copy(); |
52 |
|
|
53 |
|
//void mirror(); |
54 |
|
void mirror() { |
55 |
|
unsigned char temp[MAX_SIZE]; |
56 |
|
for (int i=0; i<m_size; i++) |
57 |
|
temp[i] = (m_size-1) - m_matrix[i]; |
58 |
|
set( temp ); |
59 |
|
} |
60 |
|
|
61 |
|
//void rotate90(); |
62 |
|
void rotate90() { |
63 |
|
unsigned char temp[MAX_SIZE]; |
64 |
|
for (int i=0; i<m_size; i++) { |
65 |
|
int x = i; |
66 |
|
int y = m_matrix[i]; |
67 |
|
temp[y] = (m_size-1) - x; |
68 |
|
} |
69 |
|
set( temp); |
70 |
|
} |
71 |
|
|
|
bool operator==(const Solution& sol); |
|
|
bool operator!=(const Solution& sol); |
|
72 |
|
|
73 |
int size() {return m_size;}; |
int size() {return m_size;}; |
74 |
void setSize(int size) {m_size = size;}; |
void setSize(int size) {m_size = size;}; |
75 |
|
private: |
76 |
bool matrix[MAX_SIZE][MAX_SIZE]; |
explicit Solution(const Solution& input); |
77 |
|
//void set(unsigned char[MAX_SIZE]); |
78 |
|
void set(unsigned char input[MAX_SIZE]) { |
79 |
|
for (int i=0; i<m_size; i++) |
80 |
|
m_matrix[i] = input[i]; |
81 |
|
} |
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
unsigned char m_matrix[MAX_SIZE]; |
86 |
protected: |
protected: |
87 |
int m_size; |
int m_size; |
88 |
|
|
89 |
}; |
}; |
90 |
|
|
91 |
#endif |
#endif |