void TacheManager::setFin(const QDate& f) { if(debut > f) throw CalendarException("La date de début dépasse la date de fin"); for (std::list<Tache*>::const_iterator it = taches.begin(); it != taches.end(); it++) { if( (*it)->getDateEcheance() > f ) throw CalendarException(getNom()+": la tâche "+(*it)->getTitre()+" possède une deadline supérieure"); } fin=f; }
void TacheManager::setDebut(const QDate& d) { if(d > fin) throw CalendarException("La date de début dépasse la date de fin"); for (std::list<Tache*>::const_iterator it = taches.begin(); it != taches.end(); it++) { if( (*it)->getDateDisponibilite() < d ) throw CalendarException(getNom()+": la tâche "+(*it)->getTitre()+" possède une échéance inférieure"); } debut=d; }
/************************************************************************************ * Description : Individu::getString() const, fonction qui retourne le * prenom, nom, le nom du departement, le nom du bureau et * prix d'entree, la liste des vins preferes, de l'individu * Parametre : String: [Prenom][Nom] -Prix: [prix d'entrée]CAD - Vins: * [liste des vins séparées par une virgule et une espace] * Valeur de retour : AUCUNE * Remarque : AUCUNE ************************************************************************************/ string Professeur::getString() const { stringstream information; information << "Professeur: " << getPrenom() << " " << getNom() << " (" << departement_<< ", " << bureau_ << ") - Prix : " << prixEntree_ << " CAD"; if(getNbVinsPreferes() != 0) { information << " Vins - "; for (int i = 0; i < getNbVinsPreferes(); i++) // encore une fois on affiche la liste des vins { // grace au stringstream. information << getVinPrefere(i); if (i != getNbVinsPreferes() - 1) { information << ", "; } } } return information.str(); }
/** * Selon les coordonnées passées en paramètre, ici le joueur selectionne un animal à poser, puis la méthode le pose sur le plateau * ensuite la méthode action de l'animal est appelé et enfin, le bonus inauguration est traité */ bool JoueurReel::jouerCase(int xPion, int yPion, Plateau* plateau, Affichage * affiche) { if (plateau->getCase(xPion, yPion)->getPion() != NULL) { cerr << "Ajout impossible du pion en case :(" << xPion << "," << yPion << ")" << endl; return false; } else { int typeAnimal = affiche->selectionnerAnimal(getListAnimaux()); int nbPion = getListAnimaux().size(); int pos = 0; // instanciation du pointeur selon le type demandé en parametre switch (typeAnimal) { // Gazelle case 1: while (pos < nbPion) { if (dynamic_cast<Gazelle*>(getListAnimaux()[pos]) == NULL) { pos++; } else { break; } } break; // Zebre case 2: while (pos < nbPion) { if (dynamic_cast<Zebre*>(getListAnimaux()[pos]) == NULL) { pos++; } else { break; } } break; // Elephant case 3: while (pos < nbPion) { if (dynamic_cast<Elephant*>(getListAnimaux()[pos]) == NULL) { pos++; } else { break; } } break; // Lion case 4: while (pos < nbPion) { if (dynamic_cast<Lion*>(getListAnimaux()[pos]) == NULL) { pos++; } else { break; } } break; // Crocodile case 5: while (pos < nbPion) { if (dynamic_cast<Crocodile*>(getListAnimaux()[pos]) == NULL) { pos++; } else { break; } } break; default: cerr << "L'animal n'existe pas" << endl; return false; } if (pos < nbPion) { // ajout de l'animal à la case plateau->ajouterAnimal(xPion, yPion, getListAnimaux()[pos]); // suppression de l'animal dans la reserve du joueur getListAnimaux().erase(getListAnimaux().begin() + pos); Animal *a = dynamic_cast<Animal*>(plateau->getCase(xPion, yPion)->getPion()); if (a == NULL) { cerr << "Erreur dans jouer (JoueurReel.cpp) : le pion posé n'est pas un animal !" << endl; // Supprimer le pion? return false; } // Appel de la fonction action du pion a->action(plateau, affiche); affiche->affichePlateau(*plateau); /* BONUS INNAUGURATION */ if (!plateau->getbonusInauguration() && plateau->secteurRempli(plateau->getCase(xPion, yPion)->getSecteur())) { ajouterPoints(5); plateau->setBonusInauguration(true); affiche->messageBonusInauguration(getNom()); } return true; } else { cerr << "L'animal n'est pas dans les pions disponibles du joueur"<< endl; return false; } } return false; }