subject

You will use the following Shape interface to implement a Circle, Triangle, and Rectangle classes. Among the method(s) required by the interface...Circles have a radiusTriangle have a base and heightRectangle have a length and a widthYou will be passed a file name contain shape data from the command line. Some kind of Executive class should read the file and use a ShapeContainer (see below) to store pointers to various shapes, using the specifications for each shape given in the file. The file also contains commands to print the area of a given shape and to exit the program. When a print command is issued, the information about the shape and it's area should be printed. Shape InterfaceYou may NOT add any public methods to this class.#include class Shape{ public: virtual double area() const = 0; virtual std::string shapeName() const = 0; virtual ~Shape() {}};ShapeContainerYou may NOT add any public methods to this class#include "Shape. h"#include class ShapeContainer{ public: ShapeContainer(int size); //initialize pointers in m_arrayOfShapes to nullptr ~ShapeContainer(); double area(int index) const; //throws a std::runtime_error if index is invalid, meaning out of range OR index has nullptr std::string shapeName(index) const; //throws a std::runtime_error if index is invalid, meaning out of range OR index has nullptr void add(Shape* shapePtr, int index); //throws a std::runtime_error if index is invalid OR if shapePtr is nullptr void remove(int index); //throws a std::runtime_error if the index is invalid OR there is no object to delete private: Shape** m_arrayOfShapes; int m_size;}File FormatThe first item in the file will be the size of the shape container, which cannot change despite how many adds are in the file. Following that will be lines containing one of the three following commands in any order:ADDis the index in the container to put the shapewill be CIR, TRI, or REC for Circle, Triangle, and Rectangle respectivelywill the be radius, base and height, or length and width, of a Circle, Triangle, or Rectangle the shape at a given indexThe index may be out of range or not yet set, in which case you must catch and handle the exception to gracefully recover and continue onPRINTPrints the name and area of the shape at a given index, as shown belowThe index may be out of range or not yet set, in which case you must catch and handle the exception to gracefully recover and continue onEXITEnds the program5ADD 0 CIR 5.5ADD 1 TRI 2.5 6.6PRINT 0ADD 2 REC 10.5 20.25PRINT 99PRINT 2 EXITSample run:Shape at index 0: Circle area = 95.0331Shape at index 99: Does not existShape at index 2: Rectangle area = 212.625Exiting...

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 01:00
Ap practice - performance task response the ap create performance task asks you to write about an abstraction that you developed and wrote into your code. most of the time that means identifying a function or procedure you wrote to "manage complexity" in your program. here is the actual prompt from the create performance task: 2d. capture and paste a program code segment that contains an abstraction you developed individually on your own (marked with a rectangle). this abstraction must integrate mathematical and logical concepts. explain how your abstraction manage the complexity of your program. (must not exceed 200 words) below is a segment of code from an "under the sea" program with a rectangle drawn around a portion of the code identifying an abstraction. imagine that you wrote this and are composing an ap response about how this abstraction manages complexity. (note: ignore the requirement that the abstraction integrate "mathematical and logical concepts" for this practice response. just write about managing complexity). explain how the abstraction marked with the rectangle in the code above manage complexity of this program. write your response here submit
Answers: 2
question
Computers and Technology, 23.06.2019 17:30
Scientists have changed the model of the atom as they have gathered new evidence. one of the atomic models is shown below. what experimental evidence led to the development of this atomic model from the one before it? a few of the positive particles aimed at a gold foil seemed to bounce back. the colors of light emitted from heated atoms had very specific energies. experiments with water vapor showed that elements combine in specific proportions. cathode rays were bent in the same way whenever a magnet was brought near them.
Answers: 2
question
Computers and Technology, 24.06.2019 09:00
Why might you chose to crest a function resume
Answers: 1
question
Computers and Technology, 24.06.2019 17:40
The value of sin(x) (in radians) can be approximated by the alternating infinite series create a function (prob3_2) that takes inputs of a scalar angle measure (in radians) and the number of approximation terms, n, and estimates sin(x). do not use the sin function in your solution. you may use the factorial function. though this can be done without a loop (more efficiently), your program must use (at least) one. you may find the mod() function useful in solving the problem.
Answers: 1
You know the right answer?
You will use the following Shape interface to implement a Circle, Triangle, and Rectangle classes. A...
Questions
question
Mathematics, 09.03.2021 19:30
question
Mathematics, 09.03.2021 19:30
question
Mathematics, 09.03.2021 19:30
question
Mathematics, 09.03.2021 19:30
question
Social Studies, 09.03.2021 19:30
Questions on the website: 13722367