CardFactory.h

Go to the documentation of this file.
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 __CARDFACTORY_H__
00029 #define __CARDFACTORY_H__
00030 
00031 #include <iostream>
00032 #include "Exception.h"
00033 #include "Card.h"
00034 #include "NumberCard.h"
00035 #include "LetterCard.h"
00036 
00037 namespace deck {
00038 
00041   template <typename cardType>
00042   class CardFactory {
00043   public:
00044     CardFactory() {};
00046     
00047     virtual ~CardFactory() {};
00049 
00050     virtual Card *createCard(int rank, enum Card::SuitType suit) {
00051       Card *pCard = NULL;
00052       try {
00053         pCard = new cardType(rank, suit);
00054       }
00055       catch (error::Exception &e) {
00056         std::cout << e << std::endl;
00057       }
00058       return pCard;
00059     }
00061     
00062   private:
00063     
00064   };
00065 }
00066 
00067 #endif

Generated on Thu Mar 6 09:44:38 2008 for carddeck by  doxygen 1.5.3