(under construction)
with Ada.Strings; with Ada.Strings.Hash; with Ada.Exceptions; use Ada.Exceptions; package body Bookstore.Books is 5 ----------------- -- Create_Book -- ----------------- 10 function Create_Book (ID : in Id_Str; Surname : in Name_Str; First_Name : in Name_Str; Title : in Title_Str; 15 Price : in Value; On_Sale : in Boolean; Calendar_Year : in Year; Description : in Description_Str; Inventory : in Inventory_Size) 20 return Book is B : Book; begin B.ID := ID; 25 B.Description := Description; B.Price := Price; B.On_Sale := On_Sale; B.Inventory := Inventory; B.First_Name := First_Name; 30 B.Surname := Surname; B.Title := Title; B.Calendar_Year := Calendar_Year; return B; end Create_Book; 35 ------------ -- Get_Id -- ------------ 40 function Get_ID (B : in Book) return Id_Str is begin return B.ID; end Get_ID; 45 --------------------- -- Get_Description -- --------------------- function Get_Description (B : in Book) return Description_Str is 50 begin return B.Description; end Get_Description; --------------- 55 -- Get_Price -- --------------- function Get_Price (B : in Book) return Value is begin 60 return B.Price; end Get_Price; ---------------- -- Is_On_Sale -- 65 ---------------- function Is_On_Sale (B : in Book) return Boolean is begin return B.On_Sale; 70 end Is_On_Sale; ------------------- -- Get_Inventory -- ------------------- 75 function Get_Inventory (B : in Book) return Inventory_Size is begin return B.Inventory; end Get_Inventory; 80 ------------ -- Set_Id -- ------------ 85 procedure Set_ID (B : in out Book; ID : in Id_Str) is begin B.ID := ID; end Set_ID; 90 --------------------- -- Set_Description -- --------------------- 95 procedure Set_Description (B : in out Book; Description : in Description_Str) is begin B.Description := Description; 100 end Set_Description; --------------- -- Set_Price -- --------------- 105 procedure Set_Price (B : in out Book; Price : in Value) is begin B.Price := Price; 110 end Set_Price; ----------------- -- Set_On_Sale -- ----------------- 115 procedure Set_On_Sale (B : in out Book; On_Sale : in Boolean) is begin B.On_Sale := On_Sale; 120 end Set_On_Sale; ------------------- -- Set_Inventory -- ------------------- 125 procedure Set_Inventory (B : in out Book; Inventory : in Inventory_Size) is begin B.Inventory := Inventory; 130 end Set_Inventory; -------------------- -- Get_First_Name -- -------------------- 135 function Get_First_Name (B : in Book) return Name_Str is begin return B.First_Name; end Get_First_Name; 140 ----------------- -- Get_Surname -- ----------------- 145 function Get_Surname (B : in Book) return Name_Str is begin return B.Surname; end Get_Surname; 150 --------------- -- Get_Title -- --------------- function Get_Title (B : in Book) return Title_Str is 155 begin return B.Title; end Get_Title; ----------------------- 160 -- Get_Calendar_Year -- ----------------------- function Get_Calendar_Year (B : in Book) return Year is begin 165 return B.Calendar_Year; end Get_Calendar_Year; -------------------- -- Set_First_Name -- 170 -------------------- procedure Set_First_Name (B : in out Book; First_Name : in Name_Str) is begin 175 B.First_Name := First_Name; end Set_First_Name; ----------------- -- Set_Surname -- 180 ----------------- procedure Set_Surname (B : in out Book; Surname : in Name_Str) is begin 185 B.Surname := Surname; end Set_Surname; --------------- -- Set_Title -- 190 --------------- procedure Set_Title (B : in out Book; Title : in Title_Str) is begin 195 B.Title := Title; end Set_Title; ----------------------- -- Set_Calendar_Year -- 200 ----------------------- procedure Set_Calendar_Year (B : in out Book; Calendar_Year : in Year) is begin 205 B.Calendar_Year := Calendar_Year; end Set_Calendar_Year; --------------- -- To_String -- 210 --------------- function To_String (B : in Book) return String is use Strings; begin 215 return "book id='" & Strings.To_String (B.ID) & "', surname='" & Strings.To_String (B.Surname) & "', first name='" & Strings.To_String (B.First_Name) & "', title='" & Strings.To_String (B.Title) & "', price='" & Value'Image (B.Price) & 220 "', on sale='" & Boolean'Image (B.On_Sale) & "', year='" & Year'Image (B.Calendar_Year) & "', desc='" & Strings.To_String (B.Description) & "', inv='" & Inventory_Size'Image (B.Inventory); end To_String; 225 end Bookstore.Books;