00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "forbiddenPattern.hpp"
00022 #include <iostream>
00023 using namespace std;
00024
00026
00030 ForbiddenPattern::ForbiddenPattern(int width, int height)
00031 : grid(width, height)
00032 {
00033 this->width = width;
00034 this->height = height;
00035 }
00036
00037
00039 ForbiddenPattern::~ForbiddenPattern()
00040 {
00041 }
00042
00043
00045
00048 int ForbiddenPattern::getWidth()
00049 {
00050 return width;
00051 }
00052
00053
00055
00058 int ForbiddenPattern::getHeight()
00059 {
00060 return height;
00061 }
00062
00063
00065
00073 bool ForbiddenPattern::cellChanged(int x, int y)
00074 {
00075 switch (grid(x, y))
00076 {
00077 case nDONTCARE:
00078 {
00079 grid(x, y) = nENABLED;
00080 break;
00081 }
00082 case nENABLED:
00083 {
00084 grid(x, y) = nDISABLED;
00085 break;
00086 }
00087 case nDISABLED:
00088 {
00089 grid(x, y) = nDONTCARE;
00090 break;
00091 }
00092 default:
00093 {
00094 }
00095 }
00096
00097 return true;
00098 }
00099
00100
00102
00105 Grid ForbiddenPattern::getGrid()
00106 {
00107 return grid;
00108 }
00109
00110
00112
00116 bool ForbiddenPattern::equals(ForbiddenPattern *fp)
00117 {
00118 return ((fp->getGrid().getCells() == grid.getCells()));
00119 }
00120
00121
00123
00126 matrix ForbiddenPattern::getMatrix()
00127 {
00128 return grid.getCells();
00129 }
00130
00131
00133
00140 void ForbiddenPattern::cellChanged(int x, int y, int status)
00141 {
00142 grid(x, y) = status;
00143 }
00144
00145
00147
00151 bool ForbiddenPattern::operator ==(ForbiddenPattern pattern)
00152 {
00153 return ((getWidth() == pattern.getWidth()) &&
00154 (getHeight() == pattern.getHeight()) &&
00155 (grid == pattern.getGrid()));
00156 }
00157
00158
00160
00163 void ForbiddenPattern::setGrid(Grid newGrid)
00164 {
00165 grid.init(newGrid);
00166 width = grid.getWidth();
00167 height = grid.getHeight();
00168 }