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 Card_h
25 #define Card_h
26 #include <iostream>
27
28 class Card
29 {
30 public:
31
Card()32 Card() {};
33 Card(int CardIndex);
34 Card(char Suit, char Rank);
35
36 //## Destructor
37 virtual ~Card();
38
39 //## Assignment Operation (generated)
40 // const Card & operator=(const Card &right);
41
42 //## Equality Operations (generated)
43
44 int operator==(const Card &right) const;
45 int operator!=(const Card &right) const;
46
47 virtual void ShowFront() const;
48 virtual void ShowBack () const;
49 char Suit () const;
50 char Rank () const;
51
52 protected:
53 private:
54
55 private: //## implementation
56 char _suit;
57 char _rank;
58 };
59
60 // Class Card
61
62 inline int Card::operator==(const Card &right) const
63 {
64 return ( _suit == right._suit &&
65 (_rank == right._rank ||
66 _rank-13 == right._rank || // for ACE
67 _rank == right._rank-13
68 )
69 );
70 }
71
72 inline int Card::operator!=(const Card &right) const
73 {
74 return !( operator == (right) );
75 }
76
Suit()77 inline char Card::Suit () const
78 {
79 return _suit;
80 }
81
Rank()82 inline char Card::Rank () const
83 {
84 return _rank;
85 }
86
87 #endif
88
89