Пример #1
0
void Client::approveIngredients( std::map<Dish*,ApprovedItem>* temp, Cafe_Menu* menu)
{
	auto dishes = menu->getMenu();
	int index = -1;
	std::vector<Dish*> indexes;
	for(auto it = temp->begin(); it != temp->end();++it)
	{
		index++;
		Dish* tempDish = static_cast<Dish*>(it->first);
		std::vector<std::tuple<IngredientKinds,bool>> tempList = it->second.ApproveIgredients;
		bool isApprove = (rand() % 100) > 50 ? true : false;
		if(isApprove)
		{
			printf_s("Client %s  has approved changes for %s\n",getFullName().c_str(),tempDish->getName().c_str());
			for(size_t i = 0; i < tempList.size();i++)
			{
				auto tempTuple = tempList.at(i);
				std::get<1>(tempTuple) = true;
			}
		}
		else
		{
			size_t index = rand() % dishes.size();
			if(index > dishes.size())
				continue;
			Dish* dish = new Dish(*dishes.at(index));
			it->second.AlternativeDish = dish;
			it->second.ApproveIgredients.clear();
			printf_s("Client %s  hasn't approved changes for %s\n",getFullName().c_str(),tempDish->getName().c_str());
			printf_s("Client %s  has chosen new dish %s\n",getFullName().c_str(),dish->getName().c_str());
			
		}
	}
}
Пример #2
0
int main(int argc, char **argv){
	DBR reasoner = DBR(argv[1],argv[2]);
	int choice = 0;
	Case prob = Case();
	Dish sol = Dish();
	while((choice = mainMenu()) != 3){
		switch(choice){
			case 1:
				reasoner.addDish(constructDish());
				break;
			case 2:
				prob = constructProblem();
				sol = reasoner.query(prob);
				cout << "You should try ";
				cout << sol.getName() <<endl;
				if(goodSuggestion()){
					reasoner.addCase(Case(prob.getLikes(), prob.getDislikes(), sol));
				}
				break;
			default:
				cout << "Unrecognized input!" <<endl;
				break;
		}
	}
	cout << "Bye!" <<endl;
	reasoner.save(argv[1],argv[2]);
	return 0;
}
Пример #3
0
void Ingridients::writeDish(QJsonObject& json, Dish& dish) const {
    QJsonArray itemsList;

    PRINT_DEBUG("Writing dish" << dish.getName());

    json["name"] = QString::fromStdString(dish.getName());
    json["amountOfPeople"] = static_cast<qint64>(dish.getAmountOfPeople());

    for ( auto& entry: dish.getIngridientMap() ) {
        QJsonObject mapEntry;
        QJsonObject food;

        writeFood(food, *(entry.first));

        mapEntry["food"] = food;
        mapEntry["amount"] = static_cast<qint64>(entry.second);

        itemsList.append(mapEntry);
    }

    json["items"] = itemsList;
}