Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello! Please help me with an explanation! Here's the instruction: INSTRUCTIONS Imagine a modle fo possibly overlapping rectangular two-dimensional window regions, like the windows for

Hello! Please help me with an explanation!

Here's the instruction:

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed
INSTRUCTIONS Imagine a modle fo possibly overlapping rectangular two-dimensional window regions, like the windows for the various open program on your computer, or a set of colored rectangles on the prior page. The order of the rectangles determine the "order" in which they would display on screen. For example, the green rectangle actually goes from (10,10) to (30,30) but you only see part of it because the rest of the rectangle is covered up by the red, blue, and yellow rectangles. In the same way the orange rectangle goes from (50,50) to (90,90) but is partially covered up by the purple, black, gray and teal rectangles. Your program will read a set of rectangles from a file, and then ask the use for a coordinate point. Using the stored data, it will determine the color of that pixel on the screen based up on the color of the rectangles. For example, given the data that created the image on the prior page, if the user asks for the color of pixel on point (25,25) the computer will think green first, as that is the first rectangle that covers that pixel, but then blue is "on top" of that, which is then "topped" by red, and finally the correct answer of "yellow" will be provided. THE MAIN PROGRAM. Your main program should do the following: It should ask the user the name for the file that they want to open up. It will then attempt to open that file and take care of the data in the file. o If the file doesn't exist/can't be found/some other error, the program should state the problem and then quit without crashing. In the file, each line is a single rectangle with the color of that rectangle given. o Your program will need to create 5 containers to hold the x, y values and the color of the rectangles. X1 Y1 X2 Y2 Color . Once the data file is read and the questions are created it will ask the user to provide a pixel they are cursious about. The program will then check all the data and find the "newest" rectangle that covers that point. It will then repeat the pixel question, until the user types in a negative value for x or y to stop the program.SAMPLE OUTPUT Your final program should look something like this: What is the name of the target file? - -> RectData . txt What is the target x coordinate? - ->1 What is the target y coordinate? - -> 1 The color of that pixel will be white. What is the target x coordinate? - -> 11 What is the target y coordinate? - -> 11 The color of that pixel will be green. What is the target x coordinate? - -> 41 What is the target y coordinate? - -> 41 The color of that pixel will be teal. What is the target x coordinate? - -> 61 What is the target y coordinate? - -> 61 The color of that pixel will be purple. What is the target x coordinate? - -> -6 What is the target y coordinate? > -5 Program Finished!PROGRAM NOTES If there are no touching rectangles, the default color is "white\". I would highly suggest the use of vectors as it will make ethe assignment easier, but arrays are allowed. I would highly suggest a function that looks like: hool pointInsidefint x1, int yl, int x2, in't yl, int pixelx, and int pixelY). A function like this will help you go through all the different rectangles quickly. Ask for help before the due date. \f

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions