public void EmprunterLivre(Livre p_livre, Abonne p_abonne) { if (p_livre == null) { throw new ArgumentNullException(nameof(p_livre)); } if (p_abonne == null) { throw new ArgumentNullException(nameof(p_abonne)); } if (!this.m_livres.Contains(p_livre)) { throw new InvalidOperationException("Le livre n'existe pas !"); } if (!this.m_abonnes.Contains(p_abonne)) { throw new InvalidOperationException("L'abonné n'existe pas !"); } if (!p_abonne.PeutEmprunter) { throw new InvalidOperationException("L'abonné ne peut pas emprunter de livres."); } if (!p_livre.EstDisponible) { throw new InvalidOperationException("Le livre n'est pas disponible."); } // Solution temporaire avant de voir comment inverser ou de compenser les actions en cas d'erreurs p_livre.Emprunter(p_abonne); }
public void Emprunter(Abonne p_abonne) { if (!this.EstDisponible) { throw new InvalidOperationException(); } p_abonne.EmprunterLivre(this); this.Emprunteur = p_abonne; this.DateEmprunt = DateProduction.Now; this.m_nombreRenouvellements = 0; }