Chapter 4 Examples

 

-- ***************************************************************************
-- *                       Ada_Store_Trading.adb 
-- * Copyright (c) Simon Johnston & Addison Wesley Longman 1996.
-- *
-- * Description: This is a simplified form of a package which exists in the
-- *    Ada_Store application. It is also the first example in section 4.2
-- * Inputs:  None.
-- * Outputs: None.
-- ***************************************************************************
package Ada_Store_Trading is
   type State is ( Trading, Not_Trading, Consolidating );
   procedure Start;
   procedure Stop;
   function Current_State return State;
   Invalid_Trading_Time : exception;
end Ada_Store_Trading;

 

-- ***************************************************************************
-- *                       Ada_Store_Trading.adb 
-- * Copyright (c) Simon Johnston & Addison Wesley Longman 1996.
-- *
-- * Description: This is a simplified form of a package which exists in the
-- *    Ada_Store application. It is also the first example in section 4.2
-- * Inputs:  None.
-- * Outputs: None.
-- ***************************************************************************
package body Ada_Store_Trading is
   Trading_State : State := Not_Trading;
   procedure Start is
      Some_Time_Test : Boolean;
   begin
      if Some_Time_Test = true then
	 
	 Trading_State := Trading;
      else
	 raise Invalid_Trading_Time;
      end if;
   end Start;
   procedure Stop is
      Some_Time_Test : Boolean;
   begin
      if Some_Time_Test = true then
	 
	 Trading_State := Not_Trading;
      else
	 raise Invalid_Trading_Time;
      end if;
   end Stop;
   
   function Current_State return State is
   begin
      return Trading_State;
   end Current_State;
end Ada_Store_Trading;

Contents Page

Copyright © 1996 Simon Johnston &
Addison Wesley Longman