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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 08:00
Digital information is stored using a series of ones and zeros. computers are digital machines because they can only read information as on or off –1 or 0. this method of computation is known as the system
Answers: 1
question
Computers and Technology, 23.06.2019 02:00
Which of the following is not a source of sustainable raw materials? a) coal mine b) flick of sheep c) cotton plantation d) line forest.
Answers: 2
question
Computers and Technology, 23.06.2019 22:20
Learning sign language is an example of a(n) learning sign language is an example of a(n)
Answers: 2
question
Computers and Technology, 24.06.2019 02:10
Which sentences describe the things you need to ensure while creating a sketch and a drawing? while an artistic or creative drawing is a creative expression, a technical drawing is an informative expression. you need to create accurate and neat drawings to convey accurate information. a technical drawing clearly conveys its meaning or information, and does not leave room for interpretation maintain a good speed while creating drawings
Answers: 1
You know the right answer?
Implementing the following object oriented programming constructions.1. Member FunctionsReplace the...
Questions
question
History, 26.07.2019 01:10
Questions on the website: 13722361