当前位置: 首页>>代码示例>>C++>>正文


C++ Cell::SetAnswerLetter方法代码示例

本文整理汇总了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;
}
开发者ID:elbeno,项目名称:xwordedit,代码行数:35,代码来源:grid.cpp

示例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)
	{
//.........这里部分代码省略.........
开发者ID:elbeno,项目名称:xwordedit,代码行数:101,代码来源:grid.cpp


注:本文中的Cell::SetAnswerLetter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。