本文整理汇总了C++中Cell::SetAnswerLetter方法的典型用法代码示例。如果您正苦于以下问题:C++ Cell::SetAnswerLetter方法的具体用法?C++ Cell::SetAnswerLetter怎么用?C++ Cell::SetAnswerLetter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cell
的用法示例。
在下文中一共展示了Cell::SetAnswerLetter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Load
bool Grid::Load(const char *filename)
{
ifstream is(filename);
if (!is.is_open())
return false;
is >> mRows;
is >> mCols;
is >> mSymmetry;
delete[] mCells;
mCells = new Cell[mRows * mCols];
bool open;
char letter;
for (Cell *pCell = mCells; pCell != &mCells[mRows * mCols]; ++pCell)
{
is >> open;
is >> letter;
if (!open)
pCell->Toggle();
pCell->SetAnswerLetter(letter);
}
is.close();
ResetWordSlots();
CalculateWordSlots();
mDirty = false;
gSignalServer.signal_grid_dirty().emit(false);
gSignalServer.signal_grid_redraw().emit();
return true;
}
示例2: LoadPUZ
bool Grid::LoadPUZ(const char *filename)
{
FILE* fp = fopen(filename, "r");
if (!fp) return false;
// puzzle size
int nResult = fseek(fp, 0x2C, SEEK_SET);
if (nResult == -1)
{
fclose(fp);
return false;
}
mRows = fgetc(fp);
mCols = fgetc(fp);
mSymmetry = NONE;
delete[] mCells;
mCells = new Cell[mRows * mCols];
// answer grid
nResult = fseek(fp, 0x34, SEEK_SET);
if (nResult == -1)
{
fclose(fp);
return false;
}
char *pString = new char[mCols + 1];
pString[mCols] = 0;
std::list<std::string> answers;
for (int i = 0; i < mRows; i++)
{
int nRead = fread(pString, 1, mCols, fp);
if (nRead != mCols)
{
fclose(fp);
return false;
}
char *pLetter = pString;
Cell *pCell = &mCells[i*mCols];
for (int j = 0; j < mCols; ++j, ++pCell, ++pLetter)
{
if (!isalpha(*pLetter))
pCell->Toggle();
else
pCell->SetAnswerLetter(*pLetter);
}
}
ResetWordSlots();
CalculateWordSlots();
// puzzle grid
for (int i = 0; i < mRows; i++)
{
int nRead = fread(pString, 1, mCols, fp);
if (nRead != mCols)
{
fclose(fp);
return false;
}
char *pLetter = pString;
Cell *pCell = &mCells[i*mCols];
for (int j = 0; j < mCols; ++j, ++pCell, ++pLetter)
{
if (isalpha(*pLetter))
{
assert(pCell->IsOpen());
pCell->SetGuessLetter(*pLetter);
}
else if (*pLetter == '-')
{
assert(pCell->IsOpen());
pCell->SetGuessLetter(0);
}
else
{
assert(*pLetter == '.');
assert(!pCell->IsOpen());
}
}
}
delete[] pString;
// puzzle headers
std::string title;
std::string author;
std::string copyright;
GetLine(fp, title);
GetLine(fp, author);
GetLine(fp, copyright);
// clue strings
std::string s;
std::list<WordSlot *>::iterator i = mWordSlots.begin();
while (GetLine(fp, s) != EOF)
{
//.........这里部分代码省略.........