home *** CD-ROM | disk | FTP | other *** search
/ vsiftp.vmssoftware.com / VSIPUBLIC@vsiftp.vmssoftware.com.tar / FREEWARE / FREEWARE40.ZIP / caribbeanstud / hands.h < prev    next >
C/C++ Source or Header  |  1997-12-07  |  3KB  |  118 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 Hands_h
  25. #define Hands_h 1
  26.  
  27. #include "Card.h"
  28.  
  29.  
  30. class Hands 
  31. {
  32.   public:
  33.         enum  Hand { EX =0,
  34.                          NP ,    
  35.                          P1 ,    
  36.                          P2 ,    
  37.                          K3 ,    
  38.                          ST ,
  39.                          FL ,
  40.                          FH ,
  41.                          K4 ,
  42.                          SF ,
  43.                          RF 
  44.       };
  45.  
  46.       Hands();
  47.       virtual ~Hands() {};
  48.  
  49.       int operator==(const Hands &right) const;
  50.       int operator!=(const Hands &right) const;
  51.       int operator>=(const Hands &right) const;
  52.       int operator<=(const Hands &right) const;
  53.       int operator>(const Hands &right) const;
  54.       int operator<(const Hands &right) const;
  55.  
  56.       virtual void  AddCard  (Card *card);
  57. #ifndef VMS
  58.       virtual Hand  HandValue                () const;
  59. #else
  60.       virtual void  HandValue    (const Hand hand);
  61. #endif
  62.       virtual long  Score                    () const;
  63.       virtual int   PayRate                () const;
  64.       virtual void  NewGame                () ;
  65.         virtual Card** Cards                 () const;
  66.         virtual int   NumOfCards           () const;
  67.       virtual const char* const HandName() const;
  68.  
  69.   protected:
  70.         virtual void  SortCards                () const;
  71.  
  72.   private:
  73.         void          ReArrange(char*, int nel, char*, Hand);
  74.       const Hands & operator=(const Hands &right);
  75.  
  76.   private:
  77.       Card*            _cards[5];
  78.         long            _score;
  79.         Hand            _hand;
  80.         int         _next;
  81.        static      const int  Ratio[11];
  82.        static      const char * HandNames[11];
  83. };
  84.  
  85. inline int Hands::operator==(const Hands &right) const
  86. {
  87.         return ( Score() == right.Score() );
  88. }
  89.  
  90. inline int Hands::operator!=(const Hands &right) const
  91. {
  92.         return ( Score() != right.Score() );
  93. }
  94.  
  95. inline int Hands::operator<=(const Hands &right) const
  96. {
  97.         return ( Score() <= right.Score() );
  98. }
  99.  
  100. inline int Hands::operator>=(const Hands &right) const
  101. {
  102.         return ( Score() >= right.Score() );
  103. }
  104.  
  105. inline int Hands::operator>(const Hands &right) const
  106. {
  107.         return ( Score() > right.Score() );
  108. }
  109.  
  110. inline int Hands::operator<(const Hands &right) const
  111. {
  112.         return ( Score() < right.Score() );
  113. }
  114.  
  115. #endif
  116.  
  117.  
  118.