TYPE Book_Type IS RECORD Title, Author, Publisher : Title_Str; Year : Year_Type; Edition : Natural; Isbn : Isbn_Type; Price : Dollars; Stock : Natural; Format : Format_Type; END RECORD; TYPE Book_Collection_Array IS ARRAY (1 .. 200) OF Book_Type; TYPE Book_Collection IS RECORD Books : Book_Collection_Array; Max_Size : Integer; Current_Size : Integer; END RECORD;
Book_Type and Book_Collection are both private. One of the packages was provided to us, and has functions to access information in Book_Type. One of the procedures I need to write is a procedure to change the price of a book, if it is in the collection. I tried this:
PROCEDURE Change_Price ( Collection : Book_Collection; ISBN : Isbn_Type; Price : Dollars) IS Seen_Book : Boolean := False; BEGIN FOR book IN Collection.Books'Range LOOP IF ISBN(Collection.Books(book)) = ISBN THEN Set_Price(Collection.Books(book), Price); Seen_Book := True; END IF; END LOOP; IF NOT Seen_Book THEN RAISE Book_Not_Found; END IF; END Change_Price;
ISBN is a provided function that takes book_type as a parameter and returns isbn_type. Set_Price is a procedure that takes Book_type and price, and sets the price in the collection. I am getting 2 errors:
1 - When I call the ISBN function, it is telling me that it is expecting an integer, not a book_type.
2 - When I call the Set_Price procedure, it is telling me that the actual for "Book" must be a variable.
I am still very new, and don't really understand this. Can anyone steer me in the right direction? Thanks!