[31m-- Skywalker is another attempt of A. i. written with Ada.[m [31m-- Skywalker is Copyright (C) 2024 Manuel De Girardi ; [m [31m--[m [31m-- This program is free software; you can redistribute it and/or modify[m [31m-- it under the terms of the GNU General Public License as published by[m [31m-- the Free Software Foundation; either version 2 of the License, or[m [31m-- (at your option) any later version.[m [31m--[m [31m-- This program is distributed in the hope that it will be useful,[m [31m-- but WITHOUT ANY WARRANTY; without even the implied warranty of[m [31m-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the[m [31m-- GNU General Public License for more details.[m [31m--[m [31m-- You should have received a copy of the GNU General Public License[m [31m-- along with this program; if not, write to the Free Software[m [31m-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA[m [31m--[m [31m-- Date := 2024-11-17 09:31:38 ; [m [31m-- Version := 0.1.0r ; [m [01;34mwith[m Sky[31m.[mStock[31m;[m [01;34muse[m Sky[31m.[mStock[31m;[m [01;34mpackage[m Sky[31m.[mStocks_manager [01;34mis[m [01;34mtype[m Stock_Array [01;34mis[m [01;34marray[m [31m([mStock_Num_Range [01;34mrange[m [31m<>)[m [01;34mof[m Stock_Record[31m;[m [01;34mtype[m [01;30mStocks_Manager[m [31m([mStocks_Max [31m:[m Stock_Num_Range[31m)[m [01;34mis[m [01;34mrecord[m Stocks [31m:[m [01;30mStock_Array[m[31m([m[35m1[m[31m..[mStocks_Max[31m);[m Stock_Last [31m:[m Stock_Num_Range [31m:=[m [35m0[m[31m;[m [01;34mend[m [01;34mrecord[m[31m;[m [01;34mprocedure[m [01;30mStock_Add[m [31m([mTo [31m:[m [01;34min[m [01;34mout[m Stocks_Manager[31m;[m Stock [31m:[m [01;34min[m Stock_Record[31m);[m [31m-- Spec_Error is raised if no space left. [m [01;34mprocedure[m [01;30mStock_Remove[m [31m([mFrom [31m:[m [01;34min[m [01;34mout[m Stocks_Manager[31m;[m Stock_Num [31m:[m [01;34min[m Stock_Num_Range[31m);[m Not_An_Stock [31m:[m [01;34mexception[m[31m;[m [31m-- Not_An_Stock is raised when not Stock_Num is not an stock.[m [01;34mprocedure[m [01;30mAdd_To_Stock[m[31m([mFrom [31m:[m [01;34min[m [01;34mout[m Stocks_Manager[31m;[m Stock_Num [31m:[m [01;34min[m Stock_Num_Range[31m;[m Qt [31m:[m [01;34min[m Quantity_Range[31m);[m [31m-- If the stock more Qt is over Quantity_Range'last, Spec_error is raised.[m [01;34mprocedure[m [01;30mAdd_To_Stock[m[31m([mFrom [31m:[m [01;34min[m [01;34mout[m Stocks_Manager[31m;[m Name [31m:[m [01;34min[m Wstring_32[31m;[m Qt [31m:[m [01;34min[m Quantity_Range[31m);[m [31m-- If the stock more Qt is over Quantity_Range'last, Spec_error is raised.[m [01;34mprocedure[m [01;30mUpdate_Stock[m[31m([mTo[31m:[m [01;34min[m [01;34mout[m Stocks_Manager[31m;[m Stock [31m:[m [01;34min[m Stock_Record[31m);[m [31m-- If the stock more Qt is over Quantity_Range'last, Spec_error is raised.[m [01;34mprocedure[m [01;30mRemove_From_Stock[m[31m([mFrom [31m:[m [01;34min[m [01;34mout[m Stocks_Manager[31m;[m Name [31m:[m [01;34min[m Wstring_32[31m;[m Qt [31m:[m [01;34min[m Quantity_Range[31m);[m [31m-- if Qt is not in the stock, Spec_Error is raised.[m [01;34mfunction[m [01;30mIn_Stocks[m [31m([mStocks [31m:[m [01;34min[m Stocks_Manager[31m;[m Description [31m:[m [01;34min[m Wstring_32[31m)[m [01;34mreturn[m [32mBoolean[m[31m;[m Software [31m:[m [01;30mStocks_Manager[m[31m([m[35m256[m[31m);[m Soft_num [31m:[m Natural [31m:=[m [35m0[m[31m;[m Hardware [31m:[m [01;30mStocks_Manager[m[31m([m[35m128[m[31m);[m Hard_Num [31m:[m Natural [31m:=[m [35m0[m[31m;[m Hard_Filename [31m:[m [01;34mconstant[m [32mString[m [31m:=[m [31m"hardstock.txt"[m[31m;[m Soft_Filename [31m:[m [01;34mconstant[m [32mString[m [31m:=[m [31m"softstock.txt"[m[31m;[m [01;34mprocedure[m Stocks_Save[31m;[m [01;34mprocedure[m Stocks_Restore[31m;[m [01;34mend[m Sky[31m.[mStocks_manager [31m;[m