1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
MariettaO [177]
3 years ago
6

Implementing the following object oriented programming constructions.1. Member FunctionsReplace the eight supporting output func

tions 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#includeusing 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";}
Computers and Technology
1 answer:
leonid [27]3 years ago
4 0

Answer:

OMG i can't read that.

Explanation:

You might be interested in
Python full code not displaying<br>only hello prints
tankabanditka [31]
From the code you posted, there is no function call to vendingMachine()

Try at the top of your code:

print ("hello")
vendingMachine()

def vendingMachine():
...
5 0
3 years ago
Three primary types of data that a forensic investigator must collect, in this order: 1.Volatile data 2.Temporary data 3.Persist
posledela

Answer:

1. volatile data

2. temporary data

3. persistent data

seems like you already got it correct

Explanation:

7 0
3 years ago
What are the odds that you find someone you know in person on here
jenyasd209 [6]

Answer:

0

Explanation:

As far as I know, no one I know, even knows that brainly exists. Those who do  know about it don't use it.

6 0
3 years ago
Is regular Facebook use healthy? Why or why not?
melamori03 [73]
No. social media makes people share too much information about their personal lives.
7 0
4 years ago
Read 2 more answers
Which best describes the benefits of renting a home?
WARRIOR [948]
The benefits are that you don't have to worry if something breaks from like a water leake or a storm and get destroyed the home owners have to pay
7 0
4 years ago
Read 2 more answers
Other questions:
  • In Linux, when logged in as a normal user with root privileges, which command must precede the apt-get command in the command li
    13·1 answer
  • Which option correctly describes a DBMS application? A. software used to manage databases B. software used to organize files and
    7·2 answers
  • To create a new query in Design view, click CREATE on the ribbon to display the CREATE tab and then click the ____ button to cre
    9·1 answer
  • What are the most common types of cables in a network?
    6·1 answer
  • Which of the following accessories would you use to create a drawing? A. Calculator B. Notepad C. Paint D. WordPad
    14·2 answers
  • In relation to data science,advances in technology has made it more feasible to do what
    5·1 answer
  • Consider the following code segment.
    12·1 answer
  • Pls help quick... will mark brainliest...
    15·1 answer
  • Which of the following statements about interpreting colors are true? Select 3 options.
    11·1 answer
  • In cell B20, enter a
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!