// Jonathan Chan // CIS15 MY9 Prof. Sokol // Assignment 2 - WAR! #include #include #include using namespace std; // Defines a SINGLE card! class card { string card_center(string); public: int value; string face; // s=spade, h=heart, d=diamond, c=club, '\0'=no suit char suit; card(int value, string face, char suit='\0'); // functions string display_card(int mode=1); }; // either outputs the card value or a graphic of the card! string card::display_card(int mode) { stringstream out; if (mode==1) { out << this->face << "-" << this->suit; } else { out << ".-------.\n"; if (this->suit == 's') out << "| * |\n" << "| * * |\n" << "|* *|\n" << "| *I* |\n"; else if (this->suit=='d') out << "| / \\ |\n" << "| / \\ |\n" << "| \\ / |\n" << "| \\ / |\n"; else if (this->suit=='c') out << "| _ |\n" << "| _( )_ |\n" << "|(_ . _)|\n" << "| I |\n"; else if (this->suit=='h') out << "| ** ** |\n" << "|* * *|\n" << "| * * |\n" << "| * |\n"; else out << "| |\n" << "| |\n" << "| |\n" << "| |\n"; out << card_center(face); out << "'-------'"; } return out.str(); } // Centers the card face on the card string card::card_center(string face) { if (face.length() > 7) face=face.substr(0,7); if (face.length() % 2 == 0) face=face.substr(0,face.length()/2)+" "+face.substr(face.length()/2); string space; for (int i=0;i<(7-face.length())/2;i++) { space+=' '; } face="|"+space+face+space+"|\n"; return face; } card::card(int value, string face, char suit) { this->value=value; this->face=face; this->suit=suit;; } class deck { card *cards; unsigned short int _size; public: static bool use_jokers; static unsigned short int size; deck(unsigned short int); // prints entire content of deck void debug(); }; // Static Variables bool deck::use_jokers=false; deck::deck(unsigned short int size=65535) { if (deck::use_jokers) deck::size=54; if (size != 65535) deck::size=size; cards=new card[deck::size]; for(int i=0;ideck::cards + ((card*)(((unsigned int)i) * 12u))) = 0' main.cpp:11: note: candidates are: card& card::operator=(const card&) main.cpp: In member function 'void deck::debug()': */