with Books;  use Books;
with Libraries;  use Libraries;
with Ada.Text_IO;  use Ada.Text_IO;

procedure Test_Libraries is

   L : Library_Type;

   procedure Print (Book : Book_Type) is
      Name : constant Name_Type := Author (Book);
   begin
      Put ("Title: "); Put_Line (Title (Book));
      Put ("Author: "); Put (Name.Last); Put (", "); Put_Line (Name.First);
      New_Line;
   end;

   Book : Book_Access;

begin

   declare
      N : constant Name_Type := New_Name ("Rick", "Santorum");
   begin
      Add (L, New_Book ("Man On Dog, Or Whatever The Case May Be", N));
      Add (L, New_Book ("Privacy Rights? What Privacy Rights?", N));
   end;

   declare
      N : constant Name_Type := New_Name ("Tom", "DeLay");
   begin
      Add (L, New_Book ("The Bug Man Cometh", N));
   end;

   declare
      N : constant Name_Type := New_Name ("George", "Bush");
   begin
      Add (L, New_Book ("Evolution: The Jury's Still Out", N));
      Add (L, New_Book ("What Country Would Jesus Bomb?", N));
      Add (L, New_Book ("Theocrats Are Just Smarter Than You", N));
   end;

   Book := New_Book ("No Man, No Problem", New_Name ("Edwin", "Vieira"));
   Add (L, Book);

   New_Line;
   Put_Line ("Books listed by title:");
   New_Line;
   Books_By_Title (L, Print'Access);
   New_Line;

   Put_Line ("Books by Rick Santorum:");
   New_Line;
   Books_By_Author (L, New_Name ("Rick", "Santorum"), Print'Access);
   New_Line;

   Put_Line ("Books by Tom DeLay:");
   New_Line;
   Books_By_Author (L, New_Name ("Tom", "DeLay"), Print'Access);
   New_Line;

   Put_Line ("Books by George Bush:");
   New_Line;
   Books_By_Author (L, New_Name ("George", "Bush"), Print'Access);
   New_Line;

   Put_Line ("Books by Matthew Heaney:");
   New_Line;
   Books_By_Author (L, New_Name ("Matthew", "Heaney"), Print'Access);
   New_Line;

   Put_Line ("Books by Edwin Vieira:");
   New_Line;
   Books_By_Author (L, New_Name ("Edwin", "Vieira"), Print'Access);
   New_Line;

   Put_Line ("Books listed by author:");
   New_Line;
   Books_By_Author (L, Print'Access);
   New_Line;

   Put_Line ("Deleting Tom DeLay, er, I mean his book...");
   Remove (L, "The Bug Man Cometh", New_Name ("Tom", "DeLay"));
   New_Line;

   Put_Line ("Books listed by title:");
   New_Line;
   Books_By_Title (L, Print'Access);
   New_Line;

   Put_Line ("No Edwin Vieira, no problem...");
   Remove (L, Book);
   New_Line;

   Put_Line ("Books listed by title:");
   New_Line;
   Books_By_Title (L, Print'Access);
   New_Line;

end Test_Libraries;
