bool Hand::isFlush()
{
if(cardVector[0].suit=cardVector[1].suit=cardVector[2].suit=cardVector[3].suit=cardVector[4].suit)return true;
return false;
}
bool Hand :: isThreeOfKind()
{
if (cardVector[4].rank=cardVector[3].rank, // comparing card 5 to 4, then card 5 to 3.
cardVector[4].rank=cardVector[2].rank)
{
return true;
}
return false;
if (cardVector[3].rank=cardVector[2].rank, //comparing card 4 to 3 and the card 4 to 2
cardVector[3].rank=cardVector[1].rank)
{
return true;
}
return false;
if (cardVector[2].rank=cardVector[1].rank,
cardVector[2].rank=cardVector[0].rank) //comparing card 3 to 2 and the card 3 to 1
{
return true;
}
return false;}
int main ()
{
cout<< "welcome" << endl;
Deck deck;
float flushCount=0;
float threeKind=0;
float count= 16000;
for(int i=0;i<count;i++)
{
deck.shuffle();
Hand hand=deck.dealHand();
if(hand.isFlush())flushCount++;
}
for (int j=0;j<count;j++)
{
Hand hand=deck.dealHand();
if (hand.isThreeOfKind())threeKind++;
}
cout << "The amount of flushes in a game run 160000 times is..."<< endl;
cout << flushCount << endl;
cout << (flushCount/count)*100 << endl;
cout << " Your have this many "<< threeKind << endl;
system("pause");
return 0;
}
当我运行代码时,我得到的值threeKind
等于 的值count
。我想要做的是在一手 5 张牌中获得三个种类的数量。我觉得里面的逻辑Hand::isThreeOfKind()
可能不正确?我试图重复我所做的bool Hand::isFlush()
。