Following is my Project 2. In Project 1, I wrote a program to draw square, rectangle and triangle and this is its second part.

I could not figure it out how to do it. Any guidelines and suggestions would be highly appreciated.

Project 2:
Our customer was pleased with the program you created for Project 1. (Go review Project 1 if you don't remember the details.) After using it, she came up with some new features for Version 2.0. As before, you're going to have to handle the technical details. The big difference is that the program should be able to draw as many shapes as the user wants, possibly overlapping, all at one time. This means the program could draw something like this:

******* **
******* ********
********** ********
****** * **
**********
*****

This is a lot more complicated! To start with, instead of sending chars directly to the screen for each shape, they should instead be stored in a char array of 60 columns and 20 rows. The array can then be sent to the screen one row at a time either when requested by the user, or perhaps after every shape is added.

Since we now have a more powerful tool called a "class", we're going to want to use it. Think about all the nouns that represent the concepts in the CUSTOMER's world: square, triangle, etc. These will be your classes. Then for each noun, think about the verbs the CUSTOMER would use with that noun, such as Draw and Erase. These will be your class methods. Besides a width and height, you'll now also need a location for each shape. The location is the row and column of the upper left corner of the shape within the drawing array. Perhaps other things besides the shapes can be represented using classes.

Caution: when drawing the shapes into the array, be sure not to draw beyond the array bounds!

You might want to use a class to manage the array that holds the drawing characters. Such a class might be defined something like this:

class Screen
{
static const int WIDTH = 60;
static const int HEIGHT = 20;
char frameBuffer[HEIGHT][WIDTH];

public:
Screen() { }
void SetPixel(int x, int y, char c); // place c in the frame buffer at location x,y
bool IsInBounds(int x, int y); // called from SetPixel to see if x,y is a legal location
void Display(); // copy the entire frame buffer to the screen
};

@MathMate

In Project 2, you are tasked with enhancing the program you created in Project 1 to be able to draw multiple shapes, possibly overlapping, all at once. The main difference is that instead of directly drawing the shapes on the screen, you will store them in a char array of 60 columns and 20 rows. This array can then be sent to the screen one row at a time when requested by the user or after every shape is added.

To achieve this, you will need to create classes for each shape (e.g., Square, Rectangle, Triangle) as well as a class to manage the drawing array (e.g., Screen).

For the shape classes, think about the nouns that represent each shape (e.g., square, rectangle, triangle). These nouns will become your classes. For each shape class, consider the verbs the customer would use with that shape (e.g., Draw, Erase). These verbs will become your class methods.

You will also need to add a location for each shape in the drawing array. The location will represent the row and column of the upper left corner of the shape within the array. Additionally, consider adding other attributes or methods to represent other aspects of the shapes if necessary.

For the class that manages the drawing array (Screen), you can define it as follows:

```cpp
class Screen
{
static const int WIDTH = 60;
static const int HEIGHT = 20;
char frameBuffer[HEIGHT][WIDTH];

public:
Screen() { } // Constructor

void SetPixel(int x, int y, char c); // Method to place character c in the frame buffer at location x, y
bool IsInBounds(int x, int y); // Method called from SetPixel to check if x, y is a valid location within the array bounds
void Display(); // Method to copy the entire frame buffer to the screen
};
```

The `Screen` class has a member variable `frameBuffer` which is a 2-dimensional char array representing the drawing area. It also has methods `SetPixel` which places a character at a specified location in the frame buffer, `IsInBounds` which checks if a given location is within the array bounds, and `Display` which copies the entire frame buffer to the screen.

To implement Project 2, you will need to create the necessary shape classes (e.g., Square, Rectangle, Triangle) with appropriate attributes and methods to support drawing and erasing the shapes in the frame buffer. You will also need to update the main program logic to handle multiple shapes and their drawing and erasing operations using the `Screen` class and the shape classes you have created.

I hope this provides you with some guidelines and suggestions for implementing Project 2. If you have any specific questions or need further assistance, feel free to ask.