Exemple #1
0
/*
* Methode qui vérifie s’il est possible que l'abonne emprunte un livre.
* @param Un Abonne et un Livre.
* @return Un bool.
*/
bool Bibliotheque::estEmpruntable(const Abonne & abonne, const Livre & livre) const
{	
	unsigned int k;
	bool retour = (
		(livre.obtenirNbDisponibles() >= 1) &&
		(abonne.obtenirAge() >= livre.obtenirAgeMinimal()) &&
		(!(abonne.estEmprunte(livre, k))));
	return retour;
}
Exemple #2
0
bool Bibliotheque::estEmpruntable(const string& matricule, const ObjetEmpruntable& objetEmpruntable) const
{
	Abonne* abonne = trouverAbonne(matricule);
	bool estEmprunte = false;

	for (unsigned int i = 0; i < emprunts_.size() && !estEmprunte; i++)
		if (emprunts_[i]->obtenirMatricule() == matricule && emprunts_[i]->obtenirObjetEmpruntable()->obtenirCote() == objetEmpruntable.obtenirCote())
			estEmprunte = true;

	return objetEmpruntable.obtenirNbDisponibles() > 0 && objetEmpruntable.obtenirAgeMinimal() < abonne->obtenirAge() &&
		!estEmprunte && abonne->obtenirNombreEmprunte() < abonne->obtenirEmpruntsLimite();
}