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

can you guys help me to change the all variables to a diferent name and all clas

ID: 3757433 • Letter: C

Question

can you guys help me to change the all variables to a diferent name and all classes to a diferent names as well

++++++card.cpp+++++

#pragma once

#include <string>

#include <iostream>

#include <vector>

#include "Card.h"

using namespace std;

string Card::faces[] = { "", "Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King" };

string Card::suits[] = { "Hearts", "Spdaes", "Clubs", "Diamonds" };

Card::Card(int face, int suit)

{

this->face = face;

this->suit = suit;

}

string Card::toString()

{

string mid_wrd = " of ";

return faces[face] + mid_wrd + suits[suit];

}

++++++card.h+++++

#pragma once

#include <string>

#include <iostream>

#include <vector>

using namespace std;

class Card

{

private:

int face, suit;

static string faces[14];

static string suits[4];

public:

Card(int face, int suit);

string toString();

};

+++++Deckofcards.cpp+++++

#pragma once

#include <string>

#include <iostream>

#include <vector>

#include "DeckOfCards.h"

using namespace std;

DeckOfCards::DeckOfCards()

{

current_Card = 0;

for (int i = 0; i < 52; ++i)

{

cards.push_back(Card((i % 13) + 1, i / 13));

}

}

void DeckOfCards::function_shufle()

{

int r_i;

for (int i = 0; i < 52; ++i)

{

r_i = rand() % 52;

Card temp = cards[i];

cards[i] = cards[r_i];

cards[r_i] = temp;

}

}

Card DeckOfCards::dealCard()

{

return cards[current_Card++];

}

bool DeckOfCards::moreCards()

{

return current_Card < 52;

}

++++Deckofcards.h++++++

#pragma once

#include <string>

#include <iostream>

#include <vector>

#include "Card.h"

using namespace std;

class DeckOfCards

{

private:

vector<Card> cards;

int current_Card;

public:

DeckOfCards();

void function_shufle();

Card dealCard();

bool moreCards();

};

++++Driver.cpp+++++

#include <string>

#include <iostream>

#include <vector>

#include "Card.h"

#include "DeckOfCards.h"

using namespace std;

int main()

{

DeckOfCards obj;

obj.function_shufle();

while (obj.moreCards()) {

cout << obj.dealCard().toString() << endl;

}

system("pause");

return 0;

}

Explanation / Answer

Please find the modified code below.

CODE

======================

++++++DeckCard.cpp+++++

#pragma once

#include <string>

#include <iostream>

#include <vector>

#include "DeckCard.h"

using namespace std;

string DeckCard::faceValues[] = { "", "Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King" };

string DeckCard::suitValues[] = { "Hearts", "Spdaes", "Clubs", "Diamonds" };

DeckCard::DeckCard(int face, int suit)

{

this->faceValue = face;

this->suitValue = suit;

}

string DeckCard::toString()

{

string mid_wrd = " of ";

return faceValues[faceValue] + mid_wrd + suitValues[suitValue];

}

++++++DeckCard.h+++++

#pragma once

#include <string>

#include <iostream>

#include <vector>

using namespace std;

class DeckCard

{

private:

int faceValue, suitValue;

static string faceValues[14];

static string suitValues[4];

public:

DeckCard(int face, int suit);

string toString();

};

+++++Deck.cpp+++++

#pragma once

#include <string>

#include <iostream>

#include <vector>

#include "Deck.h"

using namespace std;

Deck::Deck()

{

current = 0;

for (int i = 0; i < 52; ++i)

{

allCards.push_back(DeckCard((i % 13) + 1, i / 13));

}

}

void Deck::function_shufle()

{

int r_i;

for (int i = 0; i < 52; ++i)

{

r_i = rand() % 52;

DeckCard temp = allCards[i];

allCards[i] = allCards[r_i];

allCards[r_i] = temp;

}

}

DeckCard Deck::dealCard()

{

return allCards[current++];

}

bool Deck::moreCards()

{

return current < 52;

}

++++Deck.h++++++

#pragma once

#include <string>

#include <iostream>

#include <vector>

#include "DeckCard.h"

using namespace std;

class Deck

{

private:

vector<DeckCard> allCards;

int current;

public:

Deck();

void function_shufle();

DeckCard dealCard();

bool moreCards();

};

++++Driver.cpp+++++

#include <string>

#include <iostream>

#include <vector>

#include "DeckCard.h"

#include "Deck.h"

using namespace std;

int main()

{

Deck obj;

obj.function_shufle();

while (obj.moreCards()) {

cout << obj.dealCard().toString() << endl;

}

system("pause");

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote