C++ (Qt)#ifndef CARD_H#define CARD_H #include <QtGui/QtGui> class Card: public QObject{ Q_OBJECT enum Suit { Crosses, Spades, Hearts, Diamonds } m_suit; enum Value { Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King, Ace } m_value; QPixmap m_face;public: Card (Suit _suit, Value _value, QObject *_parent = NULL); /*Card (const Card &_card); Card ();*/}; #endif // CARD_H
C++ (Qt)#include "card.h" Card::Card (Suit _suit, Value _value, QObject *_parent) : QObject (_parent){ m_suit = _suit; m_value = _value;
C++ (Qt)#ifndef ABSTRACTPOKERPLAYER_H#define ABSTRACTPOKERPLAYER_H #include "card.h"#include "abstractplayer.h" class AbstractPokerPlayer: public AbstractPlayer{ Q_OBJECT QVector<Card> m_cards; public: AbstractPokerPlayer (const QString& _name, double _balance = 10000.0, QObject *_parent = NULL); public slots: void slotAddCard (const Card &_card); virtual void slotDoStep (QString& _playerName, const QVector<AbstractStep> &_steps);}; #endif // ABSTRACTPOKERPLAYER_H
C++ (Qt)#include "abstractpokerplayer.h" AbstractPokerPlayer::AbstractPokerPlayer (const QString &_name, double _balance, QObject *_parent) : AbstractPlayer(_name, _balance, _parent){ m_cards.resize (2);} void AbstractPokerPlayer::slotAddCard (const Card &_card){ if (m_cards.size () <= 2) m_cards.push_back (_card); }
C++ (Qt)MyClass* obj = new MyClass;AbstractPokerPlayer* obj2 = new AbstractPokerPlayer;QObject::connect(obj, SIGNAL(mySignal(const Card&)), obj2, SLOT(slotAddCard(const Card&)));
#ifndef ABSTRACTPOKERPLAYER_H#define ABSTRACTPOKERPLAYER_H#include "card.h"#include "abstractplayer.h"class AbstractPokerPlayer: public AbstractPlayer{ Q_OBJECT QVector<Card> m_cards;public: AbstractPokerPlayer (const QString& _name, double _balance = 10000.0, QObject *_parent = NULL);public slots: void slotAddCard (Card *_card); virtual void slotDoStep (QString& _playerName, QVector<AbstractStep> *_steps);};#endif // ABSTRACTPOKERPLAYER_H
#include "abstractpokerplayer.h"AbstractPokerPlayer::AbstractPokerPlayer (const QString &_name, double _balance, QObject *_parent) : AbstractPlayer(_name, _balance, _parent){ m_cards.resize (2);}void AbstractPokerPlayer::slotAddCard (Card *_card){ if (m_cards.size () <= 2) m_cards.push_back (*_card); }
m_cards.push_back (*_card);