Question
Please help, here is the skeleton for the main.cpp (Instructions are below.) (The last picture is a .h file which shall not be modified) (Note
Please help, here is the skeleton for the main.cpp (Instructions are below.) (The last picture is a .h file which shall not be modified) (Note in the picture where it shows the output the text from the prompt (> ) up to the end of the line is typed by the user, whereas the prompt and line without a prompt are program output.
#include
using namespace std;
#include "globals.h" #include "shape.h"
// This is the shape array, to be dynamically allocated shape** shapesArray;
// The number of shapes in the database, to be incremented // everytime a shape is successfully created int shapeCount = 0;
// The value of the argument to the maxShapes command int max_shapes;
// helper functions you write here
int main() {
string line; string command; cout "; // Prompt for input getline(cin, line); // Get a line from standard input
while (!cin.eof()) { // Put the line in a linestream for parsing // Making a new sstream for each line so the flags are cleared stringstream lineStream (line);
// Read from string stream into the command // The only way this can fail is if the eof is encountered lineStream >> command;
// Check for the command and act accordingly
// Once the command has been processed, prompt for the // next command cout "; // Prompt for input getline(cin, line); // Get the command line } // End input loop until EOF. return 0; }
Here is the skeleton for shape.cpp{
#include #include using namespace std;
#include "shape.h"
// Write the implementation (and only the implementation) of the shape // class below
}
Create a program with two parts. The first part: writes a command parser that provides a textual input interface to your program. The parser takes a sequence of commands as input. The commands create, delete modify and display shapes to be drawn on the screen Each command consists of an operation keyword followed by arguments The command and the arguments are separated by one or more spaces Thus, the code should take input from the standard input, parse it, verify that it is correct, print a response or error message and either create, delete or modify shape objects that represent the shapes specified in the command The command parser loops, processing input if input is available In the second part implement a simple "database" of objects that stores the created shapes. To do so, you will implement a class called shape that is used to store the shape properties Create and maintain a dynamically allocated array of pointers to shape objects to keep track of shape objects created and deleted Do not draw the shapes to the screen, just process the commands and maintain the database of the shape objects Requirements: 1. Input and output must be done only using the C++standard library streams cin and cout 2. The stream input operator >> and associated functions such as fail) and eof) shall be used for all input. C-style IO such as printf and scanf shall not be used Strings shall be stored using the C++ library type string, and operations shall be done using its class members, not C-style strings. 3. 4. C-library string-to-integer conversions (including but not limited to atoi, strtol, etc) shall not be used Argument Description, type, and range a string consisting of any non-whitespace characters3; except strings that represent commands, shape types or the reserved word all a string that represents the type of a shape and must be one of: ellipse, rectangle or triangle a positive integer (0 or larger) that represents the location of the shape in either the x or y dimension a positive integer (0 or larger) that represents the size of the a shape in either the x or y dimension a positive integer (0 or larger) that represents the maximum number of shapes in the database a positive integer between 0 and 360 that represents angle of rotation of a sha ame type loc size value ang le Table 1: Acceptable input arguments Create a program with two parts. The first part: writes a command parser that provides a textual input interface to your program. The parser takes a sequence of commands as input. The commands create, delete modify and display shapes to be drawn on the screen Each command consists of an operation keyword followed by arguments The command and the arguments are separated by one or more spaces Thus, the code should take input from the standard input, parse it, verify that it is correct, print a response or error message and either create, delete or modify shape objects that represent the shapes specified in the command The command parser loops, processing input if input is available In the second part implement a simple "database" of objects that stores the created shapes. To do so, you will implement a class called shape that is used to store the shape properties Create and maintain a dynamically allocated array of pointers to shape objects to keep track of shape objects created and deleted Do not draw the shapes to the screen, just process the commands and maintain the database of the shape objects Requirements: 1. Input and output must be done only using the C++standard library streams cin and cout 2. The stream input operator >> and associated functions such as fail) and eof) shall be used for all input. C-style IO such as printf and scanf shall not be used Strings shall be stored using the C++ library type string, and operations shall be done using its class members, not C-style strings. 3. 4. C-library string-to-integer conversions (including but not limited to atoi, strtol, etc) shall not be used Argument Description, type, and range a string consisting of any non-whitespace characters3; except strings that represent commands, shape types or the reserved word all a string that represents the type of a shape and must be one of: ellipse, rectangle or triangle a positive integer (0 or larger) that represents the location of the shape in either the x or y dimension a positive integer (0 or larger) that represents the size of the a shape in either the x or y dimension a positive integer (0 or larger) that represents the maximum number of shapes in the database a positive integer between 0 and 360 that represents angle of rotation of a sha ame type loc size value ang le Table 1: Acceptable input argumentsStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started