本文整理汇总了C++中Case类的典型用法代码示例。如果您正苦于以下问题:C++ Case类的具体用法?C++ Case怎么用?C++ Case使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Case类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//-----------------------------------------------------------------------------------------------
// Called by Ipopt when finished
//-----------------------------------------------------------------------------------------------
void BonminInterfaceGradients::finalize_solution(TMINLP::SolverReturn status,
Index n, const Number* x, Number obj_value)
{
cout << "IPOPT returned a status indicating ";
if ( status == Ipopt::SUCCESS ) cout << "SUCCESS";
else if ( status == Ipopt::MAXITER_EXCEEDED ) cout << "MAXITER_EXCEEDED";
else if ( status == Ipopt::CPUTIME_EXCEEDED ) cout << "CPUTIME_EXCEEDED";
else if ( status == Ipopt::STOP_AT_TINY_STEP ) cout << "STOP_AT_TINY_STEP";
else if ( status == Ipopt::STOP_AT_ACCEPTABLE_POINT ) cout << "STOP_AT_ACCEPTABLE_POINT";
else if ( status == Ipopt::LOCAL_INFEASIBILITY ) cout << "LOCAL_INFEASIBILITY";
else if ( status == Ipopt::USER_REQUESTED_STOP ) cout << "USER_REQUESTED_STOP";
else if ( status == Ipopt::FEASIBLE_POINT_FOUND ) cout << "FEASIBLE_POINT_FOUND";
else if ( status == Ipopt::DIVERGING_ITERATES ) cout << "DIVERGING_ITERATES";
else if ( status == Ipopt::RESTORATION_FAILURE ) cout << "RESTORATION_FAILURE";
else if ( status == Ipopt::ERROR_IN_STEP_COMPUTATION ) cout << "ERROR_IN_STEP_COMPUTATION";
else if ( status == Ipopt::INVALID_NUMBER_DETECTED ) cout << "INVALID_NUMBER_DETECTED";
else if ( status == Ipopt::TOO_FEW_DEGREES_OF_FREEDOM ) cout << "TOO_FEW_DEGREES_OF_FREEDOM";
else if ( status == Ipopt::INVALID_OPTION ) cout << "INVALID_OPTION";
else if ( status == Ipopt::OUT_OF_MEMORY ) cout << "OUT_OF_MEMORY";
else if ( status == Ipopt::INTERNAL_ERROR ) cout << "INTERNAL_ERROR";
else cout << "UNKNOWN_ERROR";
cout << endl;
cout << "Writing the final solution to the summary file..." << endl;
Case *c = generateCase(n,x);
c->setObjectiveValue(-obj_value);
p_optimizer->sendBestCaseToRunner(c);
}
示例2: _resetMousePosition
void SfBall::_initNewGame() {
for (std::list<Ball*>::iterator it = _balls.begin(); it != _balls.end(); ++it)
delete *it;
_balls.clear();
_map->reset(22, 26);
_resetMousePosition();
Ball* ball = new Ball(sf::Vector2f(5.5, 5.5), 0.15, _gameWorld);
ball->setName("Ball_1");
ball->setSpeed(sf::Vector2f(1, 5) * 0.5f);
*_scene << ball;
_balls.push_back(ball);
Case* current;
for (int i = 0; i < 22; ++i) {
current = new StandardCase(sf::Vector2f(i, 10), _gameWorld);
current->setColor(sf::Color::Yellow);
*_scene << current;
*_map << current;
}
for (int i = 6; i < 22; ++i) {
current = new StandardCase(sf::Vector2f(i, 5), _gameWorld);
current->setColor(sf::Color::Yellow);
*_scene << current;
*_map << current;
}
sf::View view = _window->getView();
_playerBar->setPosition(sf::Vector2f(view.getCenter().x, 1));
}
示例3: main
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;
}
示例4: PreSolve
void SfBall::PreSolve(b2Contact *contact, const b2Manifold *oldManifold) {
Object* objA = (Object*)contact->GetFixtureA()->GetBody()->GetUserData();
Object* objB = (Object*)contact->GetFixtureB()->GetBody()->GetUserData();
Ball* currentBall = dynamic_cast<Ball*>(objA);
Object* currentObject = NULL;
if (!currentBall) {
currentBall = dynamic_cast<Ball*>(objB);
currentObject = objA;
} else {
currentObject = objB;
}
if (!currentBall || !currentObject)
return ;
Case* currentCase = NULL;
Wall* currentWall = NULL;
Bar* currentBar = NULL;
if ((currentCase = dynamic_cast<Case*>(currentObject)) != NULL) {
currentCase->contact(this);
} else if ((currentWall = dynamic_cast<Wall*>(currentObject)) != NULL) {
if (currentWall == _bottomWall)
std::cout << "LOOOOSE" << std::endl;
} else if ((currentBar = dynamic_cast<Bar*>(currentObject)) != NULL) {
} else {
contact->SetEnabled(false);
return ;
}
}
示例5: getSort
Sort* PartieClient::getSort(Position* position, int id_sort)
{
Case* caseCible = this->getCase(position);
if(caseCible == NULL)
{
return NULL;
}
return caseCible->getSortId(id_sort);
}
示例6: collisionMur
bool GestionnaireCollision::collisionMur(const Fantome& fantome, const Case& mur)
{
if(fantome.estSorti())
{
if(mur.getType() != 0 && mur.getType() != 4 && mur.getType() != 5)
{
return fantome.getSprite().getGlobalBounds().intersects(mur.getRectangle().getGlobalBounds());
}
else
{
return false;
}
}
else
{
if(mur.getType() != 0 && mur.getType() != 3 && mur.getType() != 4 && mur.getType() != 5)
{
return fantome.getSprite().getGlobalBounds().intersects(mur.getRectangle().getGlobalBounds());
}
else
{
return false;
}
}
}
示例7:
Case * AngeAleatoire::choisirUneCase() {
int x = 0;
int y = 0;
int t = maPartie->monDamier->taille;
int i, j, n, r;
Case * c;
// le programme choisit un coup
n = 0; // on compte le nombre de coups possibles.
for (i=0; i<t; i++) {
for (j=0; j<t; j++) {
c = maPartie->monDamier->mesCases[i][j];
if ((c->distance(maCase)<=puissance) && !(c->estBouchee()) && (!c->estAnge()))
n++;
}
}
r = Alea::engendrer(n);
n = 0; // on selectionne un coup aleatoire dans les coups possibles.
for (i=0; i<t; i++) {
for (j=0; j<t; j++) {
c = maPartie->monDamier->mesCases[i][j];
if ((c->distance(maCase)<=puissance) && !(c->estBouchee()) && (!c->estAnge()))
if (++n == r) {
x = c->getX() + 1;
y = c->getY() + 1;
}
}
}
return c;
}
示例8: main
int main()
{
int moveNum = 0;
freopen("input.txt", "r", stdin);
for (int y = 0; y < 8; y++)
{
scanf("%s", map[y]);
}
for (int y = 0; y < 8; y++)
{
for (int x = 0; x < 8; x++)
{
if (map[y][x] == WHITE)
{
setBit(&nowCase.m_State, x, y, 1);
}
if (map[y][x] == GOAL)
{
goalX.push_back(x);
goalY.push_back(y);
}
}
}
for (;;)
{
printBoard();
char key = getch();
switch (key)
{
case 'a':
nowCase = nowCase.getNextCase(LEFT);
break;
case 'w':
nowCase = nowCase.getNextCase(UP);
break;
case 's':
nowCase = nowCase.getNextCase(DOWN);
break;
case 'd':
nowCase = nowCase.getNextCase(RIGHT);
break;
}
}
return 0;
}
示例9: attaquer
void Unite::attaquer(Case c) {
if (getJoueur()->getPtAction()<m_AttaqueParDefaut->getPtAction()) {
ManquePtAction ex;
throw ex;
}
Case cE = *(getPosition()[0]);
if ((abs(c.getX() - cE.getX()) + abs(c.getY() - cE.getY())) <= m_AttaqueParDefaut->getPortee()) {
ManquePortee ex;
throw ex;
}
m_AttaqueParDefaut->lancerAttaque(&c);
}
示例10: eval
bool Classifier::eval(Case &c,PredicateNode &pred)
{
int attribute=pred.getAttribute();
switch(schema[attribute]->getType())
{
case DISCRETE:
return c.getDiscrete(attribute)==pred.getIntValue();
case CONTINUOUS:
return c.getContinuous(attribute)<=
pred.getFloatValue();
}
}
示例11: generateCase
//-----------------------------------------------------------------------------------------------
// evaluates the model
//-----------------------------------------------------------------------------------------------
bool LshNomadEvaluator::eval_x(NOMAD::Eval_Point &x, const NOMAD::Double &h_max, bool &count_eval) const
{
// generating a case from the evaluation point
Case *c = generateCase(x);
CaseQueue *cq = new CaseQueue();
cq->push_back(c);
// sending the case off for evaluation
p_optimizer->sendCasesToOptimizer(cq);
///p_optimizer->runCase(c);
// extracting the objective
x.set_bb_output(0, -c->objectiveValue());
// extracting the constraint values
// the constraints in NOMAD must be on the form: c <= 0
for(int i = 0; i < c->numberOfConstraints(); ++i)
{
double val_input;
double val = c->constraintValue(i);
double max = p_optimizer->runner()->model()->constraints().at(i)->max();
double min = p_optimizer->runner()->model()->constraints().at(i)->min();
if(val > max) val_input = val - max;
else if(val < min) val_input = min - val;
else
{
double u_slack = max - val;
double l_slack = val - min;
val_input = (u_slack > l_slack) ? -u_slack : -l_slack;
}
x.set_bb_output(i+1, val_input);
}
// deleting the case from the heap
delete c;
delete cq;
return true;
}
示例12: FinishUpdateLoadedTexturesStatic
int Case::FinishUpdateLoadedTexturesStatic(void *pData)
{
UpdateLoadedTexturesParameters *pParams = reinterpret_cast<UpdateLoadedTexturesParameters *>(pData);
Case *pThis = pParams->pCase;
string newLocationId = pParams->newLocationId;
delete pParams;
pThis->FinishUpdateLoadedTextures(newLocationId);
return 0;
}
示例13: strtok
void ReceptionClient::traitementInfoSort()
{
char* argument[6] = {NULL};
Sort* sort = NULL;
Case* caseCible = NULL;
Joueur* proprietaire = NULL;
int x = -1, y = -1, duree = -1;
unsigned int id = 0;
for(int i = 0; i < 6; i++)
{
argument[i] = strtok (NULL, SEPARATEUR_ELEMENT);
}
for(int i = 0; i < 6; i++)
{
if(argument[i] == NULL)
{
//Info fausse
return;
}
}
x = atoi(argument[4]);
y = atoi(argument[5]);
duree = atoi(argument[3]);
id = atoi(argument[1]);
sort = this->partie->getSort(Position::fabriquePosition(x, y), id);
//Sort inexistant sur la case
if(sort == NULL)
{
sort = UsineSort::fabriqueSort(argument[0]);
//Pas de sort de ce nom
if(sort == NULL)
{
return;
}
proprietaire = this->partie->getJoueur((argument[2]));
//Pas de joueur de ce nom
if(proprietaire == NULL)
{
return;
}
sort->setProprietaire(proprietaire);
sort->setId(id);
caseCible = this->partie->getCase(Position::fabriquePosition(x, y));
//Pas de case à cette position
if(caseCible != NULL)
{
caseCible->ajouterSort(sort, duree);
}
}
}
示例14: Damier
Partie::Partie(int t, char a, char d) {
monDamier = new Damier(t);
gagnee = false;
if (a=='h') monAnge = new AngeHumain(this, 1);
if (a=='a') monAnge = new AngeAleatoire(this, 1);
Case * c = monDamier->mesCases[monDamier->taille/2][monDamier->taille/2];
c->setAnge(monAnge);
monAnge->setCase(c);
if (d=='h') monDiable = new DiableHumain(this);
if (d=='a') monDiable = new DiableAleatoire(this);
trait = monAnge;
}
示例15: initialiser
void Partie::initialiser() {
cout << "\tAnge Humain ou Aleatoire ? (h/a)" << endl;
char r;
cin >> r;
if (r=='h') monAnge = new AngeHumain(this, 1);
if (r=='a') monAnge = new AngeAleatoire(this, 1);
Case * c = monDamier->mesCases[monDamier->taille/2][monDamier->taille/2];
c->setAnge(monAnge);
monAnge->setCase(c);
cout << "\tDiable Humain ou Aleatoire ? (h/a)" << endl;
cin >> r;
if (r=='h') monDiable = new DiableHumain(this);
if (r=='a') monDiable = new DiableAleatoire(this);
trait = monAnge;
}