1 |
torben |
5 |
/*************************************************************************** |
2 |
|
|
* Copyright (C) 2005 by Torben Nielsen * |
3 |
|
|
* torben@t-hoerup.dk * |
4 |
|
|
* * |
5 |
|
|
* This program is free software; you can redistribute it and/or modify * |
6 |
|
|
* it under the terms of the GNU General Public License as published by * |
7 |
|
|
* the Free Software Foundation; either version 2 of the License, or * |
8 |
|
|
* (at your option) any later version. * |
9 |
|
|
* * |
10 |
|
|
* This program is distributed in the hope that it will be useful, * |
11 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
12 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
13 |
|
|
* GNU General Public License for more details. * |
14 |
|
|
* * |
15 |
|
|
* You should have received a copy of the GNU General Public License * |
16 |
|
|
* along with this program; if not, write to the * |
17 |
|
|
* Free Software Foundation, Inc., * |
18 |
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 |
|
|
***************************************************************************/ |
20 |
|
|
#include "solutionint.h" |
21 |
|
|
|
22 |
|
|
SolutionInt::SolutionInt(int size) |
23 |
|
|
{ |
24 |
|
|
m_size = size; |
25 |
|
|
|
26 |
|
|
for (int i=0; i<size; i++) |
27 |
|
|
{ |
28 |
|
|
m_matrix[i] = -1; |
29 |
|
|
} |
30 |
|
|
} |
31 |
|
|
|
32 |
|
|
|
33 |
|
|
SolutionInt::~SolutionInt() |
34 |
|
|
{ |
35 |
|
|
} |
36 |
|
|
|
37 |
|
|
SolutionInt::SolutionInt(const SolutionInt& input) |
38 |
|
|
: Solution() |
39 |
|
|
{ |
40 |
|
|
m_size = input.m_size; |
41 |
|
|
for (int i=0; i<m_size; i++) |
42 |
|
|
m_matrix[i] = input.m_matrix[i]; |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
bool SolutionInt::getMatrix(int x, int y) |
46 |
|
|
{ |
47 |
|
|
return (m_matrix[x] == y); |
48 |
|
|
} |
49 |
|
|
|
50 |
|
|
void SolutionInt::setMatrix(int x, int y, bool val) |
51 |
|
|
{ |
52 |
|
|
if (val == true) |
53 |
|
|
m_matrix[x] = y; |
54 |
|
|
else |
55 |
|
|
m_matrix[x] = -1; |
56 |
|
|
} |
57 |
|
|
|
58 |
|
|
bool SolutionInt::operator ==(const Solution& s) |
59 |
|
|
{ |
60 |
|
|
const SolutionInt& sol = dynamic_cast<const SolutionInt&>(s); |
61 |
|
|
for (int i=0; i<m_size; i++) |
62 |
|
|
if (m_matrix[i] != sol.m_matrix[i]) |
63 |
|
|
return false; |
64 |
|
|
return true; |
65 |
|
|
} |
66 |
|
|
/* |
67 |
|
|
bool SolutionInt::operator !=(const Solution& s) |
68 |
|
|
{ |
69 |
|
|
const SolutionInt& sol = dynamic_cast<const SolutionInt&>(s); |
70 |
|
|
return !operator==(s); |
71 |
|
|
} |
72 |
|
|
*/ |
73 |
|
|
Solution* SolutionInt::copy() |
74 |
|
|
{ |
75 |
|
|
return new SolutionInt(*this); |
76 |
|
|
} |
77 |
|
|
|
78 |
|
|
void SolutionInt::mirror() |
79 |
|
|
{ |
80 |
|
|
} |
81 |
|
|
|
82 |
|
|
void SolutionInt::rotate90() |
83 |
|
|
{ |
84 |
|
|
} |