Question: Hi I need help with a program in C++, I am having issues implementing the get rect and fill rect functions(i'll mention these later on),

Hi I need help with a program in C++, I am having issues implementing the get rect and fill rect functions(i'll mention these later on), but basically I need to create a program that will draws rectangles based on the input from the user, it will ask how many rectangles you want to draw max is 5 and then ask for an x and y for it. In the main I need help creating a 30x30 2d array filled with "."

The first function is called the DisGrid it will pass in the 2d array of chars then it will then show the contents of the grid.

the second function is call getRectangle it will have an integer parameter, then it will prompt width, height x, and y, and then make sure that the input doesn't end up surpassing the coordinates of 30, and also checking that the x and y dont pass the maximum 30 possible slots in the array, then construct the rectangle array that they g ave you and return it

You need to use a Rectangle struct with the integer values of width, height,x and y

. fillRect pass in the 2D array, a rectangle, and a character. Draw a rectangle made up of the passed in character on the grid at the rectangles x and y location with the width and height of the rectangle. Dont forget to offset the users input (1-30) to the 0 based array indexing (0-29) when drawing.

Prompt the user to enter the number of rectangles they would like to enter (1-5).

Then call the getRectangle function that many times to have the user to enter the data for each rectangle. Place each returned rectangle into the array of rectangles. Repeat for as many rectangles as the user entered. After the user enters the data for all of the rectangles, iterate through the array and call the fillRect method to draw each rectangle on the grid (remember that x is the horizontal axis, and y is the vertical axis, which is reversed from 2D array notation [row][col]), one at a time, using a different character (your choice, anything but a .) for each rectangle.

The rectangles should overlap any previously drawn rectangles.

heres an example of what the output looks like Thank you for your help

Hi I need help with a program in C++, I am having

How many rectangles would you like to draw (1-5)? 7 Invalid input. How many rectangles would you like to draw (1-5)? 3 Please enter x location of rectangle 1 (1-30): 33 Invalid input. Please enter x location of rectangle 1 (1-30): 6 Please enter y location of rectangle 1 (1-30): 6 Please enter width of rectangle 1 (1-25): 44 Invalid input. Please enter width of rectangle 1 (1-25): 6 Please enter height of rectangle 1 (1-25): 6 Please enter x location of rectangle 2 (1-30): 2 Please enter y location of rectangle 2 (1-30): 2 Please enter width of rectangle 2 (1-29): 5 Please enter height of rectangle 2 (1-29): 5 Please enter x location of rectangle 3 (1-30): 4 Please enter y location of rectangle 3 (1-30): 8 Please enter width of rectangle 3 (1-27): 4 Please enter height of rectangle 3 (1-23): 5 O. O. . . + OC + + + + X X X X X X X X X X X X X X X X * X X X X How many rectangles would you like to draw (1-5)? 7 Invalid input. How many rectangles would you like to draw (1-5)? 3 Please enter x location of rectangle 1 (1-30): 33 Invalid input. Please enter x location of rectangle 1 (1-30): 6 Please enter y location of rectangle 1 (1-30): 6 Please enter width of rectangle 1 (1-25): 44 Invalid input. Please enter width of rectangle 1 (1-25): 6 Please enter height of rectangle 1 (1-25): 6 Please enter x location of rectangle 2 (1-30): 2 Please enter y location of rectangle 2 (1-30): 2 Please enter width of rectangle 2 (1-29): 5 Please enter height of rectangle 2 (1-29): 5 Please enter x location of rectangle 3 (1-30): 4 Please enter y location of rectangle 3 (1-30): 8 Please enter width of rectangle 3 (1-27): 4 Please enter height of rectangle 3 (1-23): 5 O. O. . . + OC + + + + X X X X X X X X X X X X X X X X * X X X X

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!