Example #1
0
Position	*real::putPawn()
{
	Position *toto = NULL;

	int pos;
	std::map<std::string, int>::iterator it;
	std::string *trouduc = rofl(_map._map);

	if (REMEMBER && (it = _memory.find(*trouduc)) != _memory.end())
	{
		//std::cout << "FOUND SOMETHING AT "<< it->second << " COLOR = " << enumGame::_COLOR_::ADVICE <<  std::endl;
		pos = it->second;
		toto = new Position();
		toto->setY(pos / 17);
		toto->setX(pos % 17);
		toto->setStatus(enumGame::_COLOR_::ADVICE);
		this->_map.insert(toto);
		this->_display->clear();
		this->_display->draw(this->_map);
		this->_display->display();

		delete toto;
	}
	
	toto = NULL;
	while (!toto)
		toto = this->_display->catchEvent((this->_map));
	toto->setStatus(this->_color);
	//std::cout << "REAL AT " << toto->getY() * 17 + toto->getX() << std::endl;
	if (REMEMBER)
	{
		_disGame.push_back({ *rofl(_map._map), toto->getY() * 17 + toto->getX() });
		if (_disGame.size() > REMEMBER)
			_disGame.pop_front();
	}
	delete trouduc;
	return (toto);
}
Example #2
0
void main ()
{	
	startDay(sFile2);
	populateTextfile(sFile1);

	int i;

	do
	{
		printf("----------------------------------------------------\n");
		printf("Push 1 to sell item.\n");
		printf("Push 2 to return item.\n");
		printf("Push 3 to search stock on system.\n");
		printf("Push 4 to update stock.\n");
		printf("Push 5 to print all stock to screen.\n");
		printf("Push 6 to see cash in till for today only.\n");
		printf("Push 7 or higher to quit the program.\n");
		printf("?: ");
		scanf("%d", &i);

		switch (i)
		{
		case 1:
			printf("\n----------------------------------------------------\n");
			sellItem(sFile1, sFile2);
			printf("----------------------------------------------------\n\n");
			break;

		case 2:
			printf("\n----------------------------------------------------\n");
			returnBook (sFile1, sFile2);
			printf("----------------------------------------------------\n\n");
			break;
			
		case 3:
			printf("\n----------------------------------------------------\n");
			stockSwitch();
			printf("----------------------------------------------------\n\n");
			break;
			
		case 4:
			printf("\n----------------------------------------------------\n");
			updateStock();
			printf("----------------------------------------------------\n");
			break;
		
		case 5:
			printf("\n----------------------------------------------------\n");
			printItem(sFile1);
			printf("----------------------------------------------------\n\n");
			break;

		case 6:
			printf("\n----------------------------------------------------\n");
			cash(sFile2);
			printf("----------------------------------------------------\n\n");
			break;

		case 9:
			rofl();
			break;
		}
	}
	while (i<7 && i!=9);
	populateTextfile(sFile1);
	endStatement(sFile2);
}