本文整理汇总了C++中Card::doesShapeMatch方法的典型用法代码示例。如果您正苦于以下问题:C++ Card::doesShapeMatch方法的具体用法?C++ Card::doesShapeMatch怎么用?C++ Card::doesShapeMatch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Card
的用法示例。
在下文中一共展示了Card::doesShapeMatch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isSet
bool Deck::isSet(Card c1, Card c2, Card c3)
{
//ALL THREE CARDS MUST:
//1) have the same number or 3 different numbers
//2) have the same shading or 3 different shadings
//3) have the same shape or 3 different shapes
//4) have the same color or 3 different colors
bool numbers = false;
bool shading = false;
bool shape = false;
bool color = false;
if ((c1.doesNumberMatch(c2) && c1.doesNumberMatch(c3)) ||
!(c1.doesNumberMatch(c2) && c1.doesNumberMatch(c3)))
{
numbers = true;
}
if ((c1.doesShadingMatch(c2) && c1.doesShadingMatch(c3)) ||
!(c1.doesShadingMatch(c2) && c1.doesShadingMatch(c3)))
{
shading = true;
}
if ((c1.doesShapeMatch(c2) && c1.doesShapeMatch(c3)) ||
!(c1.doesShapeMatch(c2) && c1.doesShapeMatch(c3)))
{
shape = true;
}
if ((c1.doesColorMatch(c2) && c1.doesColorMatch(c3)) ||
!(c1.doesColorMatch(c2) && c1.doesColorMatch(c3)))
{
color = true;
}
if (numbers && shading && shape && color) //all conditions met, cards are a set
return true;
else //if not all conditions are met, it is not a set
return false;
}//checks if the 3 cards the user chooses creates a set or not...