C++ project
#include <iostream> #include <string> #include <cstdlib> using std::cin; using std::cout; using std::endl; using std::string; class Card{ public: Card(); Card(int myvalue); Card(int mysuit, int myvalue); Card(int mysuit, int myvalue, int mypoints); int GetPoints() const; string GetCardName() const; friend bool operator ==(const Card& lhs, const Card& rhs); friend bool operator <(const Card& lhs, const Card& rhs); friend bool operator >(const Card& lhs, const Card& rhs); friend const Card operator +(const Card& lhs, const Card& rhs); private: int suit; int value; int points; }; int main() { Card ah(4,1); Card kc(2,13); Card ks(1,13); Card ad(3,1); Card jd(3,11); cout << ah.GetCardName() << " == " << ad.GetCardName() << "? : " << (ah == ad) << endl; cout << ah.GetCardName() << " == " << ks.GetCardName() << "? : " << (ah == ks) << endl; cout << kc.GetCardName() << " == " << ks.GetCardName() << "? : " << (kc == ks) << endl; cout << ad.GetCardName() << " > " << ks.GetCardName() << "? : " << (ad > ks) << endl; cout << ad.GetCardName() << " > " << ah.GetCardName() << "? : " << (ad > ah) << endl; cout << jd.GetCardName() << " > " << ks.GetCardName() << "? : " << (jd > ks) << endl; cout << ks.GetCardName() << " > " << jd.GetCardName() << "? : " << (ks > jd) << endl; cout << ks.GetCardName() << " < " << jd.GetCardName() << "? : " << (ks < jd) << endl; cout << jd.GetCardName() << " < " << ks.GetCardName() << "? : " << (jd < ks) << endl; cout << ah.GetCardName() << " + " << ad.GetCardName() << "? : " << (ah + ad).GetPoints() << endl; cout << ah.GetCardName() << " + " << ad.GetCardName() << " + " << ad.GetCardName() << "? : " << (ah + ad + ad).GetPoints() << endl; cout << ah.GetCardName() << " + " << kc.GetCardName() << " + " << ks.GetCardName() << "? : " << (ah + kc + ks).GetPoints() << endl; cout << kc.GetCardName() << " + " << ah.GetCardName() << " + " << ks.GetCardName() << "? : " << (kc + ah + ks).GetPoints() << endl; cout << kc.GetCardName() << " + " << ks.GetCardName() << " + " << ah.GetCardName() << "? : " << (kc + ks + ah).GetPoints() << endl; cout << ah.GetCardName() << " + " << kc.GetCardName() << " + " << ks.GetCardName() << " + " << ad.GetCardName() << " + " << kc.GetCardName() << " + " << ad.GetCardName() << "? : " << (ah + kc + ks + ad + kc + ad).GetPoints() << endl; cout << kc.GetCardName() << " + " << ah.GetCardName() << " + " << kc.GetCardName() << " + " << ks.GetCardName() << " + " << ad.GetCardName() << " + " << kc.GetCardName() << " + " << ad.GetCardName() << "? : " << (kc + ah + kc + ks + ad + kc + ad).GetPoints() << endl; cout << kc.GetCardName() << " + 7 " << "? : " << (kc + 7).GetPoints() << endl; cout << ah.GetCardName() << " > 2 " << "? : " << (ah > 2) << endl; cout << ah.GetCardName() << " == 1 " << "? : " << (ah == 1) << endl; cout << ah.GetCardName() << " < 2 " << "? : " << (ah < 1) << endl; return 0; }