加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
card.cpp 1.03 KB
一键复制 编辑 原始数据 按行查看 历史
kevin 提交于 2021-12-07 23:24 . add file
#include "card.h"
Card::Card()
{
}
Card::Card(CardPoint point, CardSuit suit)
{
setPoint(point);
setSuit(suit);
}
void Card::setPoint(CardPoint point)
{
m_point = point;
}
void Card::setSuit(CardSuit suit)
{
m_suit = suit;
}
Card::CardPoint Card::point() const
{
return m_point;
}
Card::CardSuit Card::suit() const
{
return m_suit;
}
bool lessSort(const Card &c1, const Card &c2)
{
if(c1.point() == c2.point())
{
return c1.suit() < c2.suit();
}
else
{
return c1.point() < c2.point();
}
}
bool greaterSort(const Card &c1, const Card &c2)
{
if(c1.point() == c2.point())
{
return c1.suit() > c2.suit();
}
else
{
return c1.point() > c2.point();
}
}
bool operator ==(const Card& left, const Card& right)
{
return (left.point() == right.point() && left.suit() == right.suit());
}
uint qHash(const Card &card)
{
return card.point() * 100 + card.suit();
}
bool operator <(const Card& c1, const Card& c2)
{
return lessSort(c1, c2);
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化