-- FILE: Boxgame.adb -- AUTHOR: E.Burke -- DATE: November, 1996 -- PURPOSE: Driver procedure for Box Stacking with PLAY_FIELD; procedure Boxgame is BMAX : constant POSITIVE := 7; SMAX : constant POSITIVE := 3; IMAX : constant POSITIVE := 7; SWIDTH : constant POSITIVE := 78; SHEIGHT : constant POSITIVE := 24; -- Package PLAY_FIELD contains generic specification of BOXES and all -- operations needed to move boxes, move stacks and display boxes package Three_Stacks is new PLAY_FIELD(MAX_BOXES => BMAX, MAX_STACKS => SMAX, MAX_INPUT => IMAX, SCREEN_WIDTH => SWIDTH, SCREEN_HEIGHT => SHEIGHT); B : Three_Stacks.BOXES; S : Three_Stacks.STACKS; Continue : BOOLEAN; begin loop -- outer loop to restart Three_Stacks.Input(B,S); -- Allow user to input fixed parameters -- of each box Three_Stacks.Display(B,S); -- Display boxes (initial pattern) loop Three_Stacks.Move_Box(B,S,Continue);-- Move one box or one stack, -- according to user's input exit when not Continue; Three_Stacks.Display(B,S); -- Display boxes (updated stacks) end loop; exit when not Three_Stacks.Enquire; end loop; end Boxgame; -- comments by G. Levine -- Obviously, this needs a great deal more documentation to make it reusable -- In addition, three_stacks is neither specific nor general enough for what -- you are doing. You a really creating a package that implements a -- "BOX" with operations that initialize, move and display the BOX. -- The number of boxes (and pegs) should be part of the instantiation, not -- the hard coding.