Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

#include #include #include \"DeckOfCards.h\" // DeckOfCards class definition usi

ID: 3529648 • Letter: #

Question

#include #include #include "DeckOfCards.h" // DeckOfCards class definition using namespace std; int main() { DeckOfCards myDeckOfCards; myDeckOfCards.shuffle(); // place Cards in random order // print all 52 Cards in the order in which they are dealt for ( int i = 1; myDeckOfCards.moreCards(); ++i ) {// deal and display a Card cout << left << setw( 19 ) << myDeckOfCards.dealCard().toString(); if ( i % 4 == 0 ) // output newline every 4 cards cout << endl; } // end for } //endmain //////////////////////////////////////////////// //Card.h #ifndef CARD_H #define CARD_H #include using namespace std; class Card { public: static const int totalFaces = 13; // total number of faces static const int totalSuits = 4; // total number of suits Card( int cardFace, int cardSuit ); // initialize face and suit string toString() const; // returns a string representation of a Card // get the card's face int getFace() const { return face; } // end function getFace // get the card's suit int getSuit() const { return suit; } // end function getSuit private: int face; int suit; static const string faceNames[ totalFaces ]; static const string suitNames[ totalSuits ]; }; // end class Card #endif /////////////////////////////////////////////////////////////////////////////////////////////// //Card.cpp #include "Card.h" #include #include using namespace std; Card::Card( int cardFace, int cardSuit ) // initialize face and suit :face (cardFace), suit (cardSuit) { const string suitNames[ totalSuits ] = {"Heart", "Diamands", "Clubs", "Spades"}; const string faceNames[ totalFaces ]= {"Ace","Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"}; for (int i = 0; i < 13; i++){ for (int j = 0; j < 4; j++) { cout <<Card::faceNames [j] << "of" << Card::suitNames[i]; } } } string Card::toString() const // returns a string representation of a Card { return faceNames[ face ] + " of " + suitNames[ suit ]; } //////////////////////////////////////////////////////////////////////////////////////////////////////////// //DeckOfCards.h #ifndef DECK_OF_CARDS_H #define DECK_OF_CARDS_H #include #include "Card.h" using namespace std; // DeckOfCards class definition class DeckOfCards { public: DeckOfCards(); // constructor initializes deck void shuffle(); // shuffles cards in deck Card dealCard(); // deals cards in deck bool moreCards() const; // are there any more cards left private: std::vector< Card > deck; // represents deck of cards unsigned currentCard; // index of next card to be dealt }; // end class DeckOfCards #endif ////////////////////////////////////////////////////////////////////////////// //DeckOfCards.cpp #include "DeckOfCards.h" #include "Card.h" #include #include using namespace std; DeckOfCards::DeckOfCards() // constructor initializes deck { vector temp (52); currentCard = 0; for (int i = 0; i < Card::totalFaces; i++){ for (int j = 0; j < Card::totalSuits; j++) { temp.push_back(temp[currentCard] = Card(i,j)); currentCard++; } } } void DeckOfCards::shuffle() // shuffles cards in deck { for (int i = 0; i < 52; i++) { int randCard = rand() % 52;// not idea how this rand works,, i saw some examples but im still confused deck.push_back(deck[i]);// makes card number = 53 //For each Card, randomly select another Card in the deck and swap the two Cards. Card t = deck[i]; deck[i] = deck[randCard]; deck[randCard] = t; } } //A dealCard function that returns the next Card object from the deck. Card DeckOfCards::dealCard() // deals cards in deck { return deck[currentCard++]; } //A moreCards function that returns a bool value indicating whether there are more Cards to deal. bool DeckOfCards::moreCards() const // are there any more cards left { if(currentCard <= 52) return true; else return false; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// error DeckOfCards.cpp 1>c:program files (x86)microsoft visual studio 10.0 cincludememory(631): error C2512: 'Card::Card' : no appropriate default constructor available 1> c:program files (x86)microsoft visual studio 10.0 cincludememory(672) : see reference to function template instantiation 'void std::_Uninit_def_fill_n<_FwdIt,_Diff,_Tval,_Alloc,Card>(_FwdIt,_Diff,const _Tval *,_Alloc &,_Valty *,std::_Nonscalar_ptr_iterator_tag)' being compiled 1> with 1> [ 1> _FwdIt=Card *, 1> _Diff=unsigned int, 1> _Tval=Card, 1> _Alloc=std::allocator, 1> _Valty=Card 1> ] 1> c:program files (x86)microsoft visual studio 10.0 cinclude ector(864) : see reference to function template instantiation 'void std::_Uninitialized_default_fill_n<_Ty>>(_FwdIt,_Diff,const _Tval *,_Alloc &)' being compiled 1> with 1> [ 1> _Ty=Card, 1> _FwdIt=Card *, 1> _Diff=unsigned int, 1> _Tval=Card, 1> _Alloc=std::allocator1> ] 1> c:program files (x86)microsoft visual studio 10.0 cinclude ector(857) : while compiling class template member function 'void std::vector<_Ty>::resize(unsigned int)' 1> with 1> [ 1> _Ty=Card 1> ] 1> c:users\documents isual studio 2010projectsdeckofcardsdeckofcardsdeckofcards.h(16) : see reference to class template instantiation 'std::vector<_Ty>' being compiled 1> with 1> [ 1> _Ty=Card 1> ] 1> 1>Build FAILED. 1> 1>Time Elapsed 00:00:01.65 ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Explanation / Answer

can you please arrange in a manner and repost it .it is horrible to read sorry