Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Cpp File (Lab05.Cpp) #Include Card.H #Include ?Vector? #Include ?String? #Include ?Deque? #Include ?Iostream? #Include ?Algorithm? #Include #include card.h #include #include #include #include > #include #include

Cpp File (Lab05.Cpp) #Include \"Card.H\" #Include ?Vector? #Include ?String? #Include ?Deque? #Include ?Iostream? #Include ?Algorithm? #Include

#include \"card.h\" #include #include #include #include

> #include #include #include #include

using namespace std;

bool parenCheck(string toCheck); string stringReverse(string toReverse); void buildAndDeal();

int myRand(int i) { return rand()%i; }

/*DO NOT CHANGE MAIN OR THE FUNCTION DECLARATIONS*/

int main() { //paren strings string paren1 = \"(()((((()()()((()(((()()()()(((()(()()()(())()())()()))))()()()))()))()())())())))\"; string paren2 = \"()((((((()(((((()((()()()()()(()))))))))()))()(())(())(((((()()(())))(()()())(()))\"; string paren3 = \"(()((()(()()(()(((((()()(()()()((((()()(()()))()))))()()())))))()()())()()))())())\"; string paren4 = \"(()()(((()()(()(()()(()()()()()()(()(((((((((())())))))()))))()()))()())()()))()))\"; string paren5 = \"(())(()(())()(()(()()((())()(()(()()(()()()()())((()((())(())(()))(())())(()())())\"; string paren6 = \"()(()(()))((())((()()()(()()((((()(()((()()(())()(())()())()(()()))(((())))())(())\";

//strings to reverse string rev1 = \"sekopog\"; string rev2 = \"racecar\"; string rev3 = \"regnolsignirtssiht\"; string rev4 = \"wonybnwodsihtevahyllufepohdluohssyuguoy\";

//Putting the strings in the vector vector parens; parens.push_back(paren1); parens.push_back(paren2); parens.push_back(paren3); parens.push_back(paren4); parens.push_back(paren5); parens.push_back(paren6);

vector rever; rever.push_back(rev1); rever.push_back(rev2); rever.push_back(rev3); rever.push_back(rev4);

//this is the function call for the card deck //you will need to complete the function. cout buildAndDeal(); cout // Now the string checks with deques //call the parenCheck for(int i=0; i6;> { cout\"checking> if(parenCheck(parens.at(i))) { cout\"> } else { cout\"> } }

//now to reverse some strings for(int i =0; i4;> { cout\"reversing> cout } }

void buildAndDeal() { /* For this function you will be using a vector to build a standard 52 card deck, and then dealing a hand of 5 cards. Remeber a deck of cards has 4 suits, hearts, diamonds, spades, clovers and each suit has 13 cards 2,3,4,5,6,7,8,9,10,Jack,Queen,King,Ace

*/ //vector declaraion //need card* as we will be storing pointers //we do this to add the cards dynamically vector myDeck; //here is an example of declaring cards /* //putting a new card in the deck myDeck.push_back(new card);*>

Want an example of setting the face and suit? Look at card.h for the functions and read through the code below to see how to access functions */ //build a deck of card int position = 0; for(int i = 0; i 4;> { //your code goes Here //hint think about suits

for(int j = 0; j 13;> { //your code goes Here //hint think about face

position++; } } //print deck, make sure you have it all!

// DO NOT CHANGE THESE FOLLOWING TWO LINES OF CODE // OR THE FUNCTION UP TOP // it will break and you will be sad srand(unsigned(time(NULL))); random_shuffle(myDeck.begin(), myDeck.end(),myRand);

cout\"here> for(int i =0; i();> { coutgetSuit()\">getFace() } }(i)->(i)->

bool parenCheck(string toCheck) { deque checker; //declare my queue /* Your code goes here */ return false; } string stringReverse(string toReverse) { deque reverse; string newString = \"\"; /* Your code goes here */ return newString; }

HEADER FILE (card.h)

#ifndef CARD_H #define CARD_H #include

using namespace std;

struct card { private: string suit; string face;

public: void setSuit(string newSuit) { suit = newSuit; } void setFace(string newFace) { face = newFace; } string getSuit() { return suit; } string getFace() { return face; } }; #endif

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

11.20. How could a hexagon design be run in two orthogonal blocks?

Answered: 1 week ago