subject

Implementing the following object oriented programming constructions.1. Member FunctionsReplace the eight supporting output functions with member functions in the eight struct s. Name the functions as you like, but name them all the same. Their prototypes inside the structs should all look exactly alike, all with exactly one parameter -- an ostream reference. Modify the function called from the console and file output loops in int main accordingly.2. Stream ManipulatorsReplace the formatting code blocks in each output function with the manipulators provided in the module.3. Conditional OperatorsIf you have not already done so, apply the conditional operator so that there are no more if-else statements to convert tokens to dimensions.#include#include#include #include#include#include#include#in cludeusing namespace std;struct Square{ double side;};void outputSquare(ostream&, const Square&);struct Rectangle{ double length; double width;};void outputRectangle(ostream&, const Rectangle&);struct Circle{ double radius;};void outputCircle(ostream&, const Circle&);struct Triangle{ double side;};void outputTriangle(ostream&, const Triangle&);struct Cube{ double side;};void outputCube(ostream&, const Cube&);struct Box{ double length; double width; double height;};void outputBox(ostream&, const Box&);struct Cylinder{ double radius; double height;};void outputCylinder(ostream&, const Cylinder&);struct Prism{ double side; double height;};void outputPrism(ostream&, const Prism&);vector parseString(string);int main(){ ifstream infile("Shapes. input. txt"); ofstream fout; fout. open("Shapes. output. txt"); vector bag; vector bagType; string str; vector tokens; while (!infile. eof()) { getline(infile, str); tokens = parseString(str); if (tokens. size() != 0) { if (tokens[0] == "SQUARE") { Square* s = new Square(); if (tokens. size() > 1) s->side = atof(tokens[1].c_str()); else s->side = 0; bag. push_back(s); bagType. push_back(1);}//there's way more shapes, I just had to cut it out to make this question shorter else { if (tokens[0] == "EOF") continue; cout << tokens[0] << " Invalid Object" << endl; } } } for (unsigned int i = 0; i < bag. size(); i++) { if (bagType[i] == 1) { Square* xSquare = reinterpret_cast(bag[i]); Square& ySquare = *xSquare; outputSquare(cout, ySquare); } }//there's way more shapes, I just had to cut it out to make this question shorter for (unsigned int i = 0; i < bag. size(); i++) { if (bagType[i] == 1) { Square* xSquare = reinterpret_cast(bag[i]); Square& ySquare = *xSquare; outputSquare(fout, ySquare); } }//there's way more shapes, I just had to cut it out to make this question shorter for (unsigned int i = 0; i < bag. size(); i++) { if (bagType[i] == 1) { Square* xSquare = reinterpret_cast(bag[i]); delete xSquare; } }//there's way more shapes, I just had to cut it out to make this question shorter fout. close(); return 0;}vector parseString(string str){ stringstream s(str); istream_iterator begin(s), end; return vector(begin, end);}void outputSquare(ostream& fout, const Square& s){ double area, perimeter; area = s. side * s. side; perimeter = 4 * s. side; fout << "SQUARE side = " << s. side << " area = " << fixed << setprecision(2) << area << " perimeter = " << fixed << setprecision(2) << perimeter << "\n";}

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 06:00, Disd112984
Which statement is true of web-based social media? a. they allow consumers to interact with and update content. b. they cannot be updated easily, as compared to print media. c. they are expensive to produce and maintain, as compared to print and television. d. they can exist independent of the internet.
Answers: 1
image
Computers and Technology, 24.06.2019 13:00, sparkyjones02
Which best describes the condition under which the unicode output is the same as plain text ?
Answers: 1
image
Computers and Technology, 25.06.2019 01:00, mrstealyogirl40
Holly created a professional development plan to explore how she could advance from her entry-level position to the next step in her career. she has identified her current skills and the skills needed for the job she wants. what should she do now? a) ask a colleague for advice about work-life balance b) identify her areas for improvement c) plan a vacation before she begins her new job d) wait until a position opens before continuing her plan
Answers: 1
image
Computers and Technology, 25.06.2019 05:40, Juancr4539
How to make a negative number positive in excel
Answers: 3
You know the right answer?
Implementing the following object oriented programming constructions.1. Member FunctionsReplace the...

Questions in other subjects: