home *** CD-ROM | disk | FTP | other *** search
/ vsiftp.vmssoftware.com / VSIPUBLIC@vsiftp.vmssoftware.com.tar / FREEWARE / FREEWARE40.ZIP / caribbeanstud / deck.h < prev    next >
C/C++ Source or Header  |  1997-01-31  |  2KB  |  71 lines

  1. /*
  2.  * (c) Copyright 1997, Qun Zhang.
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software
  5.  * and its documentation for any purpose is hereby granted without fee,
  6.  * provided that the above copyright notice appear in all copies and
  7.  * that both that copyright notice and this permission notice appear in
  8.  * supporting documentation, and that the name of Qun Zhang not be used
  9.  * in advertising or publicity pertaining to distribution of the software
  10.  * without specific, written prior permission.  Qun Zhang make no
  11.  * representations about the suitability of this software for any purpose.
  12.  * It is provided "as is" without express or implied warranty.
  13.  *
  14.  * THE ABOVE-NAMED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  16.  * EVENT SHALL THE ABOVE-NAMED BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  18.  * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  19.  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  20.  * PERFORMANCE OF THIS SOFTWARE.
  21.  *
  22.  */
  23.  
  24. #ifndef Deck_h
  25. #define Deck_h 1
  26.  
  27. #include <sys/types.h>
  28. #include <time.h>
  29. #include "Card.h"
  30.  
  31. class Deck 
  32. {
  33.   public:
  34.       Deck(int numOfCards);
  35.       ~Deck();
  36.  
  37.       Card *     GetCard    () ;
  38.       void        Shuffle    () ;
  39.       void         Cut        () ;
  40.       void         Wash        () ;
  41.       int         CardsLeft() const;
  42.  
  43.   protected:
  44.  
  45.   private:
  46.       Deck(const Deck &right);
  47.       const Deck & operator=(const Deck &right);
  48.       int operator==(const Deck &right) const;
  49.       int operator!=(const Deck &right) const;
  50.  
  51.   private:
  52.         int   _numOfCards;
  53.         int   _position;  // point to the next card to be dealed
  54.         Card * _cards[54];
  55.         static Card _globalCards[54];
  56.         static int  _globalInit;
  57. };
  58.  
  59.  
  60. inline Card * Deck::GetCard() 
  61. {
  62.     return _cards[ _position++ ];
  63. }
  64.  
  65. inline int Deck::CardsLeft() const
  66. {
  67.     return _numOfCards-_position;
  68. }
  69.  
  70. #endif
  71.