home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / utility / v12n02.zip / NEWOBJ.FRG < prev    next >
Text File  |  1992-01-05  |  1KB  |  43 lines

  1.  
  2. TYPE
  3.   CardValueType = RECORD
  4.     Suit : SuitType; { An enumeration of Clubs...Spades }
  5.     Spot : SpotType; { An enumeration of Ace..King }
  6.   END; { CardValueType }
  7.  
  8.   CardType = object(TObject)
  9.     :
  10.     :
  11.     constructor Init(var CardValue : CardValueType);
  12.     :
  13.     :
  14.   end; { CardType }
  15.  
  16. CONSTRUCTOR DeckType.Init(NumDecks : Byte;
  17.                           CardKind : Pointer;
  18.                           CardCons : Pointer);
  19. VAR
  20.   I, L : Word;
  21.   J    : SpotType;
  22.   K    : SuitType;
  23.   Card : CardValueType;
  24. BEGIN
  25.   L := 0;
  26.   FOR I := 1 TO NumDecks DO
  27.     FOR K := Clubs TO Spades DO
  28.       FOR J := Ace TO King DO
  29.         BEGIN
  30.           Inc(L);
  31.           Card.Spot := J; { Setup the values to be passed }
  32.           Card.Suit := K; { to the constructor }
  33. { Create a new instance of the descendant card type }
  34.           Cards[L]  := CardTypePtr(NewByType(CardKind,
  35.                                    CardCons,
  36.                                    Card));
  37.         END;
  38. END;
  39.  
  40.  
  41. {In a different unit, or the main program...}
  42. MyDeck.Init(8,TypeOf(WindowCards),@WindowCards.Init);
  43.