Exemple #1
0
int main() {

	cout << "ALL FUNCTIONS SHOULD WORK." << endl;

	// Call the card constructors
	cout << "Calling card constructors." << endl;
	Card cFour(Card::Clubs, 4);
	Card dFour(Card::Diamonds, 4);
	Card sTen(Card::Spades, 10);
	Card hJack(Card::Hearts, 11);
	Card hQueen(Card::Hearts, 12);
	Card cQueen(Card::Clubs, 12);
	Card sQueen(Card::Spades, 12);
	Card hKing(Card::Hearts, 13);
	Card hAce(Card::Hearts, 14);
	Card defaultConstruct;
	cout << endl;

	cout << "Calling card print methods." << endl;
	sQueen.print();
	cFour.print();
	cQueen.print();
	dFour.print();
	hQueen.print();
	defaultConstruct.print();
	cout << endl;

	cout << "Printing cards using .suit() and .points()" << endl;
	cout << pointsToText(sQueen.points()) << " of " << suitToText(sQueen.suit())
			<< endl;
	cout << pointsToText(cFour.points()) << " of " << suitToText(cFour.suit())
			<< endl;
	cout << pointsToText(cQueen.points()) << " of " << suitToText(cQueen.suit())
			<< endl;
	cout << pointsToText(dFour.points()) << " of " << suitToText(dFour.suit())
			<< endl;
	cout << pointsToText(hQueen.points()) << " of " << suitToText(hQueen.suit())
			<< endl;
	cout << endl;

	cout << "Creating hand and empty hand using constructors" << endl;
	PokerHand emptyHand;
	PokerHand fullHouseQ4(sQueen, cFour, cQueen, dFour, hQueen);
	PokerHand twoPairQ4A(cFour, hQueen, cQueen, dFour, hAce);
	PokerHand twoPairQ4J(dFour, hJack, hQueen, cQueen, cFour);
	PokerHand highAKQ104(dFour, hQueen, hKing, sTen, hAce);
	PokerHand highAKJ104(hKing, sTen, hAce, hJack, cFour);
	cout << endl;

	cout << "Printing cards using PokerHand::printCards()" << endl;
	cout << "Empty Hand:" << endl;
	emptyHand.printCards();
	cout << "Full House Q-4:" << endl;
	fullHouseQ4.printCards();
	cout << "High AKJ104:" << endl;
	highAKJ104.printCards();
	cout << endl;

	cout << "Printing rank using PokerHand::printRank()" << endl;
	emptyHand.printRank();
	fullHouseQ4.printRank();
	cout << endl;

	// All the PokerHand::is...() functions are called in PokerHand::getRank() when it ran in the constructor.
	cout << "Print rank from getRank()" << endl;
	cout << rankToText(emptyHand.getRank()) << endl;
	cout << rankToText(fullHouseQ4.getRank()) << endl;
	cout << endl;

	cout << "Print is___() method results" << endl;
	cout << "isRoyalFlush(): " << fullHouseQ4.isRoyalFlush() << endl;
	cout << "isStraightFlush(): " << fullHouseQ4.isStraightFlush() << endl;
	cout << "isFourOfAKind(): " << fullHouseQ4.isFourOfAKind() << endl;
	cout << "isFullHouse(): " << fullHouseQ4.isFullHouse() << endl;
	cout << "isFlush(): " << fullHouseQ4.isFlush() << endl;
	cout << "isStraight(): " << fullHouseQ4.isStraight() << endl;
	cout << "isThreeOfAKind(): " << fullHouseQ4.isThreeOfAKind() << endl;
	cout << "isTwoPair(): " << fullHouseQ4.isTwoPair() << endl;
	cout << "isOnePair(): " << fullHouseQ4.isOnePair() << endl;
	cout << "isHighCard(): " << fullHouseQ4.isHighCard() << endl;
	cout << "These were called in getRank() when it first ran with NoRank called from the constructor." << endl;
	cout << endl;

	cout << "A couple comparisons.";
	cout << "Empty Host vs. Q-4 FullHouse: " << resultToText(emptyHand.cmp(fullHouseQ4)) << endl;
	cout << "Q-4-A 2P Host vs. Q-4 FullHouse: " << resultToText(twoPairQ4A.cmp(fullHouseQ4)) << endl;
	cout << "Q-4 FH Host vs. Q-4-J 2P: " << resultToText(fullHouseQ4.cmp(twoPairQ4J)) << endl;
	cout << "Q-4-A 2P Host vs. Q-4-J 2P: " << resultToText(twoPairQ4A.cmp(twoPairQ4J)) << endl;
	cout << "A-K-Q-10-4 High Host vs. A-K-J-10-4 High: " << resultToText(highAKQ104.cmp(highAKJ104)) << endl;
	cout << endl;

	return 0;
}