00001 /* 00002 * carddeck is an implementation of a deck of cards. 00003 * 00004 * Copyright (C) 2008 Thomas Repantis <trep@cs.ucr.edu> 00005 * 00006 * This file is part of carddeck. 00007 * 00008 * carddeck is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation, either version 3 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * carddeck is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with carddeck. If not, see <http://www.gnu.org/licenses/>. 00020 */ 00021 00022 // 00026 // 00027 00028 #ifndef __CARD_H__ 00029 #define __CARD_H__ 00030 00031 #include <string> 00032 #include "Exception.h" 00033 00034 namespace deck { 00035 00037 class Card { 00038 public: 00040 enum SuitType { 00041 CLUB = 1, 00042 DIAMOND, 00043 HEART, 00044 SPADE 00045 }; 00046 00047 Card(int rank, enum SuitType suit) throw(error::Exception); 00049 00050 virtual ~Card(); 00052 00053 virtual std::string view() const = 0; 00055 // The way the name is printed differs between 00056 // cards with letters and cards with numbers. 00057 00058 protected: 00059 int rank_; 00061 00062 enum SuitType suit_; 00064 00065 private: 00066 00067 }; 00068 00069 inline std::ostream &operator<<(std::ostream &out, const Card &card) { 00070 return out << card.view(); 00071 } 00073 00074 } 00075 00076 #endif