This is CardPile.rtf in view mode; [Download] [Up]
CardSet Release 2.1 CardPile Inherits From: Object Declared In: CardPile.h Class Description Instances of this class provide low-level functionality for card games. CardPiles contain an ordered list of Card objects which can be added to, removed from, or shuffled by clients of the class. Instance Variables id cardList; cardList A List of Card objects in this CardPile. cardSize The size of cards held by this CardPile. Method Types Initializing the class object + initialize Creating and freeing ± free ± init - initForCardSize: Card size ± setCardSize: ± returnSize Manipulating individual cards - addCard: - addCopyOfPile: - addPile: - cardAt: - cardIndex: - insertCard:at: - insertCopyOfPile:at: - insertPile:at: - removeCard: Manipulating the deck - addDeck - cardCount - empty - flip - freeCards - shuffle Archiving - read: - write: Class Methods initialize + initialize Initializes the class object. Seeds the random number generator. Returns self. See also: + initialize (Object) Instance Methods addCard: - addCard:aCard Adds Card aCard to the top of the pile. The Card object is not copied; only its id is stored in the pile. Returns self. See also: ± insertCard:at: addDeck - addDeck Adds a deck of 52 cards to the top of the pile, neatly ordered. Returns self. See also: ± shuffle addPile: - addPile:aCardPile Adds the cards in the CardPile aCardPile to the top of the receiving pile. The Card objects are not copied; only their ids are stored in the pile. Returns self. See also: ± insertPile:at: cardAt: - cardAt:(int)aPosition Returns the Card object which is located at aPosition in the CardPile. Returns nil if there is no Card at the specified index. The constants CS_TOP and CS_BOTTOM can be used to specify the top and bottom of the pile, respectively. See also: ± cardIndex: cardCount - (int)cardCount Returns the number of Card objects in the pile. cardIndex: - (int)cardIndex:aCard Returns the index of aCard in the CardPile. Returns NX_NOT_IN_LIST if the card isn't in the pile. See also: ± cardAt: addCopyOfPile: - addCopyOfPile:aPile Allocates copies of the cards in the CardPile aPile and adds them to the top of the receiving pile. The cards in the original pile are not modified. Returns self. See also: ± insertCopyOfPile:at: empty - empty Empties the card list describing the pile. The Card objects are not freed. Returns self. See also: ± freeCards flip - flip Turns the pile over, reversing the order of the cards and the orientation of each card. Returns self. free - free Deallocates all the cards in the receiving pile, and the CardPile itself. Returns nil. See also: ± init freeCards - freeCards Empties the pile and frees all the Card objects in the pile. Returns self. See also: ± empty init - init Initializes a CardPile by calling return [self initForCardSize:CS_SMALL]. See also: ± free initForCardSize: - initForCardSize:(CardSize)aSize Initializes a CardPile to hold cards of the indicated size. The pile will contain 0 cards. Returns self. Constant Description CS_SMALL Small cards CS_LARGE Big cards See also: ± free insertCard:at: - insertCard:aCard at:(int)aPosition Adds aCard to the pile at the position specified by aPosition. The constants CS_TOP and CS_BOTTOM can be used to specify the top and bottom of the pile, respectively. If you specify a value for aPosition which is greater than the number of cards in the pile, the card will not be inserted. The Card object is not copied; only its id is stored in the pile. Returns self. See also: ± addCard: insertCopyOfPile:at: - insertCopyOfPile:aCardPile at:(int)aPosition Allocates copies of the cards in aCardPile and adds them to the receiving pile at the position specified by aPosition. The constants CS_TOP and CS_BOTTOM can be used to specify the top and bottom of the pile, respectively. The cards in aCardPile are not modified. See also: ± addCard: insertPile:at: - insertPile:aCardPile at:(int)aPosition Inserts the cards in the CardPile aCardPile into the receiving pile at the position aPosition. The constants CS_TOP and CS_BOTTOM can be used to specify the top and bottom of the pile, respectively. The Card objects are not copied; only their ids are stored in the pile. Returns self. See also: ± initSuit:value:, ± initSuit:value:faceUp: read: - read:(NXTypedStream *)stream Reads and returns an object of class CardPile from stream. removeCard: - removeCard:aCard Removes the card aCard from the pile. The Card object is not deallocated. Note that this is the only way to remove a card from the pile. Returns nil if the aCard wasn't in the CardPile, otherwise returns aCard. returnSize - (CardSize)returnSize Returns the current card size for this CardPile. See also: ± addDeck setCardSize: - setCardSize:(CardSize)aSize Set the size of cards the pile can hold. If there are cards in the pile, they are set to aSize. Returns self. Constant Description CS_SMALL Small cards CS_LARGE Big cards See also: ± initForCardSize:, - returnSize shuffle - shuffle Randomly re-orders all Card objects contained in the pile. Returns self. See also: ± addDeck write: - write:(NXTypedStream *)stream Writes the receiver to stream. Returns self.
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.