Exemple #1
0
bool Bibliotheque::ajouterAbonne(Abonne& abonne)
{
	if (trouverAbonne(abonne.obtenirMatricule())== nullptr)
	{
		abonnes_.push_back(&abonne);
		return true;
	}
	return false;
}
Exemple #2
0
/*
* Methode qui vérifie si l'emprunt peut se faire en verifiant tout les conditions.
* @param Un string matricule, cote et un int date.
* @return Un bool.
*/
bool Bibliotheque::emprunter(const string & matricule, const string & cote, const int & date)
{
	bool retour = false;
	unsigned int iAbonne = 0;
	unsigned int iLivre = 0;

	Livre * livre = trouverLivre(cote);
	Abonne * abonne = trouverAbonne(matricule, iAbonne);

	if (estEmpruntable(*abonne, *livre))
	{
		if (abonne->obtenirNombreEmprunte() < 2) 
		{			
			Emprunt* emprunt = new Emprunt(abonne->obtenirMatricule(), livre, date);
			livre->modifierNbDisponibles(livre->obtenirNbDisponibles() - 1);
			abonne->ajouterEmprunt(emprunt);
			vecEmprunt_.push_back(emprunt);
			retour = true;
		}
	}

	return retour;
}
Exemple #3
0
void Bibliotheque::ajouterAbonne(Abonne& abonne)
{
	if (trouverAbonne(abonne.obtenirMatricule()) == nullptr)
		vecAbonne_.push_back(&abonne);
}
Exemple #4
0
Emprunt::Emprunt(Livre* livre, Abonne& abonne, const unsigned int& dateRetour) : matricule_(abonne.obtenirMatricule()), livre_(livre), dvd_(nullptr), dateRetour_(dateRetour)
{

}