with Bowling_Games; package Kegler_Kings_Bowlers is package BG renames Bowling_Games; type Bowler_Type is private; --There are 21 possible results of a frame: 1: 10 (strike), 2: 9-1, --3: 9-0, 4: 8-2, 5: 8-1, 6: 8-0, 7: 7-3, ..., 20: 5-1, 21: 5-0 subtype Frame_Event_Range is Positive range 1..21; type Event_Freq_Type is array (Frame_Event_Range) of Natural; --<<<< c o n s t r u c t o r >>>> function Create ( Name : String; Freq : Event_Freq_Type ) return Bowler_Type; ----------------------------------------------------------- --pre: Sum of elements in Freq is greater than zero --post: Let B be value returned by the function, and let F -- be the sum of the elements in Freq(1..21). -- Then Name_of(B) = Name and, for each i in the range -- 1..21, the probability of B achieving outcome i in a -- given frame is Freq(i)/F. ------------------------------------------------------------ procedure Create ( Bowler : out Bowler_Type; Name : in String; Freq : in Event_Freq_Type ); ----------------------------------------------------------- --pre: same as function above --post: Bowler = Create(Name, Freq) ------------------------------------------------------------ --<<<< o b s e r v e r s >>>> function Name_of( Bowler : Bowler_Type ) return String; --<<<< c o m m a n d s >>>> function Play_Game( Bowler : Bowler_Type ) return BG.Game_Type; ------------------------------------------------------------ --pre: Bowler has been "created" using one of the Create -- constructors --post: value returned is a complete game played by Bowler, -- generated using pseudo-random numbers and in accord -- with Bowler's propensities, as specified in creation. ------------------------------------------------------------- --<<< p r i v a t e >>> private type Bowler_Type_Aux; type Bowler_Type is access Bowler_Type_Aux; end Kegler_Kings_Bowlers;