Search for question
Question

1. Objectives

The objectives of this assignment are for you to practice: (1) the use of C++ I/O streams, including error handling. (2) writing a simple class with

constructors, accessors and mutators, and (3) dynamic allocation and de-allocation of one-dimensional arrays. You will do so through the design of a

program that parses drawing commands from the standard input, displaying appropriate error messages if necessary, and by creating and maintaining

objects that represent drawn shapes.

2. Problem Statement

The assignment consists of two main parts. In the first part, you will write 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 you will

write for this part of the assignment 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 as long as

input is available.

In the second part of the assignment, you will 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. Further, you will create and maintain a dynamically allocated array of pointers to Shape

objects to keep track of Shape objects created and deleted.

In this assignment, you will not actually draw the shapes to the screen, just process the commands and maintain the database of the Shape objects./n4.1. Coding Requirements

1. The code you will write shall be contained in only two source files named parser.cpp and Shope.cpp. Skeletons of the two files are released with

the assignment's zip file. The zip file also contains two .h files: globals.h and Shape.h). These files are NOT to be modified in any way. Modifying

these files often results in a mark of 0 for the assignment.

However, you may make use of helper functions to split up the code for readability and to make it easier to re-use. These functions (and their

prototypes) must be in one of the aforementioned two .cpp files. That is, you must not add any new .h or .cpp files.

2. Input and output must be done only using the C++ standard library streams cin and cout.

3. The stream input operator

scanf() shall not be used.

and associated functions such as fail() and eof() shall be used for all input. C-style 10 such as printf() and

4. Strings shall be stored using the C++ library type string, and operations shall be done using its class members, not C-style strings.

5. C-library string-to-integer conversions (including but not limited to atoi), strtol(), etc) shall not be used.

Fig: 1

Fig: 2