示例#1
0
 public void AddBook(Livre book)
 {
     livres.Add(book);
 }
示例#2
0
 private static void Item_onAvailabalityChange(Livre l)
 {
     Console.WriteLine(l);
 }
示例#3
0
 public void AddBook(Livre b)
 {
     Books.Add(b);
 }
示例#4
0
        static void Main(string[] args)
        {
            Library library = new Library();

            library.Registration(Person.getTestInstance());
            Livre lTemp = Livre.GetTestInstance();

            lTemp.IsAvailableChanged += L_IsAvailableChanged;
            library.AddBook(lTemp);

            bool running = true;

            do
            {
                Console.WriteLine("1) Afficher les livres empruntés d'une personne \n" +
                                  "2) Chercher un livre\n" +
                                  "3) Gérer les emprunts et les retours");
                String step = Console.ReadLine();
                switch (step)
                {
                case "1":
                    AfficherLivrePersonne(library);
                    break;

                case "2":
                    ChercherUnLivre(library);
                    break;

                case "3":
                    Console.WriteLine("Entrez l'ISBN du livre à retourner\\emprunter ");
                    String ISBNTemp = Console.ReadLine();
                    Livre  l2       = library.GetBook(ISBNTemp);
                    if (l2 is null)
                    {
                        Console.WriteLine("Livre introuvable");
                    }
                    else
                    {
                        Console.WriteLine("Entrer l'id de la personne :");
                    }
                    String tempRes      = Console.ReadLine();
                    int    idPerson     = Int32.Parse(tempRes);
                    Person resultPerson = library.GetPerson(idPerson);
                    if (resultPerson is null)
                    {
                        Console.WriteLine("Personne introuvable");
                    }
                    else
                    {
                        switch (l2.IsAvailable)
                        {
                        case true:             //emprunter
                            BorrowBookState result = library.Borrow(idPerson, ISBNTemp);
                            if (result != BorrowBookState.TransactionOK)
                            {
                                Console.WriteLine(result);
                            }
                            break;

                        case false:             //rendre
                            BorrowBookState result2 = library.Return(idPerson, ISBNTemp);
                            if (result2 != BorrowBookState.TransactionOK)
                            {
                                Console.WriteLine(result2);
                            }
                            break;
                        }
                        break;
                    }
                    break;

                default:
                    Console.WriteLine("Erreur !");
                    break;
                }
                Console.WriteLine("Continuer le programme ? (Y/N)");
                String run = Console.ReadLine();
                if (run != "Y")
                {
                    running = false;
                }
            } while(running);
示例#5
0
 public void removeBook(Livre b)
 {
     Books.Remove(b);
 }