*/
Stuck? Need help? Ask questions on our forums.
*/

View \SETS.PAS

This is the second disk of the PASCAL TUTOR system. It has the

Submitted By: WEBMASTER
Rating: (Not rated) (Rate It)


(* Chapter 8 - Program 3 *)
program Define_Some_Sets;

type Goodies = (Ice_Cream,Whipped_Cream,Banana,Nuts,Cherry,
                Choc_Syrup,Strawberries,Caramel,Soda_Water,
                Salt,Pepper,Cone,Straw,Spoon,Stick);

     Treat = set of Goodies;

var  Sundae         : Treat;
     Banana_Split   : Treat;
     Soda           : Treat;
     Ice_Cream_Cone : Treat;
     Nutty_Buddy    : Treat;
     Mixed          : Treat;
     Index          : byte;

begin
                (* define all ingredients used in each treat *)
   Ice_Cream_Cone := [Ice_Cream,Cone];
   Soda := [Straw,Soda_Water,Ice_Cream,Cherry];
   Banana_Split := [Ice_Cream..Caramel];
   Banana_Split := Banana_Split + [Spoon];
   Nutty_Buddy := [Cone,Ice_Cream,Choc_Syrup,Nuts];
   Sundae := [Ice_Cream,Whipped_Cream,Nuts,Cherry,Choc_Syrup,
              Spoon];

                 (* combine for a list of all ingredients used *)

   Mixed := Ice_Cream_Cone + Soda + Banana_Split + Nutty_Buddy +
            Sundae;
   Mixed := [Ice_Cream..Stick] - Mixed; (* all ingredients not used *)

   if Ice_Cream     in Mixed then Writeln('Ice cream not used');
   if Whipped_Cream in Mixed then Writeln('Whipped cream not used');
   if Banana        in Mixed then Writeln('Bananas not used');
   if Nuts          in Mixed then Writeln('Nuts are not used');
   if Cherry        in Mixed then Writeln('Cherrys not used');
   if Choc_Syrup    in Mixed then Writeln('Chocolate syrup not used');
   if Strawberries  in Mixed then Writeln('Strawberries not used');
   if Caramel       in Mixed then Writeln('Caramel is not used');
   if Soda_Water    in Mixed then Writeln('Soda water is not used');
   if Salt          in Mixed then Writeln('Salt not used');
   if Pepper        in Mixed then Writeln('Pepper not used');
   if Cone          in Mixed then Writeln('Cone not used');
   if Straw         in Mixed then Writeln('Straw not used');
   if Spoon         in Mixed then Writeln('Spoon not used');
   if Stick         in Mixed then Writeln('Stick not used');
end.

corner
© 1996-2008 CommunityHeaven LLC. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
North American business development: Nicolai Wadstrom. Publisher: Lars Hagelin.