Computational Sequence Class
MC logo

Computational Sequence Class

Ada Code Examples

<<Sequnce Class Body Download Computational Sequence Class Body>>
-- Computational counter.
with SeqPack; use SeqPack;
package CompCount is
   -- I would like to make this private, but then I couldn't access the
   -- fields inside the descendent classes.  There's apparently no Ada
   -- version of "protected," at least that I've found yet.
   type ComputationalSequence is abstract new Sequence with record
      Val, Inc: Integer;
   end record;

   -- Init stuff.
   procedure Init(S: in out ComputationalSequence'class; Start, Step: Integer);

   -- Get the current item.
   function Value(S: ComputationalSequence) return Integer;

end CompCount;
<<Sequnce Class Body Computational Sequence Class Body>>