Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ Need my output sorted to dictionary order. The cards recognize the group they need to be in, i just need them to print out

c++ Need my output sorted to dictionary order. The cards recognize the group they need to be in, i just need them to print out in order. My code is included below.

The numbers are ordered 1, 2, 3, the shading is ordered empty, striped, filled, the color is ordered brown, orange, yellow, and the shapes are ordered circle, square, triangle.

Each group is output by first sorting the cards in the group, and then printing out each of the cards in the group (using the same format as the input file) separated by a period and a space.

image text in transcribed

// Class to represent a Card class SetCard { public: SetCard() {}; SetCard(int n, string s, string c, string f); int num; string shape; string color; string fills; string toString(); };

// constructor SetCard::SetCard(int n, string s, string c, string f) { num = n; shape = s; color = c; fills = f; }

// String representation of card string SetCard::toString() { ostringstream oss; oss

int main() {

bool stop = false; // to keep track of when to stop

do { cout > fname;

SetCard cards[1000]; int len = 0;

// if done entered stop the program if (fname.compare("done") == 0) stop = true; else { ifstream infile(fname.c_str()); int n; string s, c, f;

while (infile >> n >> s >> c >> f) // reading from input file line by line { SetCard card(n, s, c, f); // create Card object cards[len] = card; // Add it to an array len++; }

bool isFound = false; for (int i = 0; i

// If even 1 set isn't found, show the below message if (!isFound) cout

} while (!stop);

return 0; }

messages Microsot Vis Studio O A https://wwwchegg.comstudyma/post View Project Build Debug Team Tool window Help * > S | Dehlig a pad File Edit Format view Help that i need it to look like: Example .exe, output sorted My code, i got them to recognize the sets, but need output sorted Crpty green diamond, 1 cmpty purple squ iEely,1 cmpty red cal empty green diased,1 striped green diamond, 1 tilled green diamond 2 eroty green diamond, 1 striped purple diamond, I filled r Crpty green diamond,1 st d purple squively, illed red ova empty green diased,1 striped red squiggly,1 tiled purple oval 2 eroty green diamond, 2 empty green diamond, 3 empty green diamond empty green diamond, 2 crupty green oval,3 empty green squial ely green diner aply gy squiggly, empty gre enoty Areen diamond,2 empty purple squiggly.3 empty red oval Crpty green diamond, 2 striped purple oval, 3 led red squieely empty green diased, 2 striped red diamond, 3 tilled purple di 2 eroty green diamond, 2 filled green diamond, 3 striped green diamond Crpty green diamond, 2 filled green oval, 3 striped green squirply ely green diner d, 2 +illed pn pl. 2 eroty green diamond, 2 filled purple squiggly.3 striped red oval Crpty green diamond, 2 filled red squiggly, striped purple oval ely gr quiggly,1 iped purple dy ed red 2 eroty green squiggly,1 striped red oval, 1 filled purple diamond 1 Crpty green squiggly,2 crupty green diamond, 3 Crpty green oval eply green squiggly,,2 empt B aply gy 2 eroty green squiggly,2 empty green squiggly , 3 empty green squietly Crpty green squiggly,2 striped green oval, led green diamond ely gr quiggly,2 iped purple diemurd, 3 tilled red ovel 2 eroty green squiggly,2 striped red diamond, 3 filled purple oval Crpty green squiggly,2 filled green wal, 3 striped green diamond empty green squiggly, 2 tilled purple diased, 3 striped red ovel 2 eroty green squiggly,2 filled red diamond, 3 striped purple oval Crpty purple squigly,1 striped green diamond illed red ova Squiggly. empty green diamond, 2 stripe d purple diamond, 2 illed red diamond 2 empty green diarid, 2 tiled purple diarid, 2 strip 2 empty green diamond, 3 enty purple squiggly, 1 enty red oval empty green diamond, 3 illed green diamond, 1 striped green diamond 2 empty gry iped gre 2 empty green diamond, 3 filled purple squiggly, 1 striped red oval empty green diamond, 3 empty green oval, 1 empty green SquiEEly 2 empty green diaried, tiled red val, 1 striped purpl 2 empty green diamond, 3 striped red diamond, 1 filled purple diamond empty green diamond, 3 illed purple oval, 1 striped red squinely 2 empty gry opty purp. 2 empty green diamond, 2 filled red squiggly, 2 striped purple oval empty green diamond, 3 cmpty green diamond, 1 cripty green diamond 2 empty green diamond, 2 empty green squigel . ipty B empty red diamond, 1 enmpty purple squiggly, 2 empty green oval empty red diamond, 2 striped purple diamond, 1 illed green diamond empty 2 +illed pi striped gr B empty red diamond , 3 enty purple squiggly , 3 empty green oval empty red diamond, 2 illed green oval, 1 striped purple squiezly empty 2 +illed by striped pi B empty red diamond, 2 striped red diamond , 1 filled red diamond empty red diamond , 3 illed purple oval, 3 stripe d green squinely empty opty purp 3 empty gry B empty red diamond, 3 striped green diamond, 3 filled purple diamond empty red diamond, 3 striped red ova) 3 illed red squinely empty striped red squiggly. led B empty red diamond, 2 filled red squiggly, 1 striped red oval empty red diamond, 3 capty green say leEly, 3 Crpty purple oval 83 "g Setc. to string)

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_2

Step: 3

blur-text-image_3

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

Big Data 29th British National Conference On Databases Bncod 2013 Oxford Uk July 2013 Proceedings Lncs 7968

Authors: Dan Olteanu ,Georg Gottlob ,Christian Schallhart

2013th Edition

3642394663, 978-3642394669

Students also viewed these Databases questions

Question

=+44-6 Discuss predictors of happiness and how we can be happier.

Answered: 1 week ago

Question

What is conservative approach ?

Answered: 1 week ago