CS 0007 Assignment 2 – Overlapping Rectangles
Objective:
Write a program that asks the user for the coordinates of the upper-left and lower-right corners of two rectangles and then computes the coordinates of the upper-left and lower-right corners of the rectangle that’s formed when the two overlap (if any).
Requirements:
procedure gatherpoints (var x1a,y1a,x2a,y2a,x1b,y1b,x2b,y2b:integer);
(x1a,y1a) are the coordinates of the upper-left point of the first rectangle.
(x2a,y2a) are the coordinates of the lower-right point of the first rectangle.
(x1b,y1b) are the coordinates of the upper-left point of the second rectangle.
(x2b,y2b) are the coordinates of the lower-right point of the second rectangle.
function overlap (x1a,y1a,x2a,y2a,x1b,y1b,x2b,y2b:integer;var x1,y1,x2,y2:integer):boolean;
(The function takes the coordinates through pass by value, sends the overlap coordinates out through pass by variable, and returns a boolean value.)
Example I/O:
Enter x and y coordinate for upper-left of rectangle 1: 0 0
Enter x and y coordinate for lower-right of rectangle 1: 100 100
Enter x and y coordinate for upper-left of rectangle 2: 40 40
Enter x and y coordinate for lower-right of rectangle 2: 120 60
Overlap is (40,40) (100,60)
Run again? (Y/N) y
Enter x and y coordinate for upper-left of rectangle 1: 0 40
Enter x and y coordinate for lower-right of rectangle 1: 100 60
Enter x and y coordinate for upper-left of rectangle 2: 40 0
Enter x and y coordinate for lower-right of rectangle 2: 200 60
Overlap is (40,40) (100,60)
Run again? (Y/N) y
Enter x and y coordinate for upper-left of rectangle 1: 0 0
Enter x and y coordinate for lower-right of rectangle 1: 100 100
Enter x and y coordinate for upper-left of rectangle 2: 20 20
Enter x and y coordinate for lower-right of rectangle 2: 40 40
Overlap is (20,20) (40,40)
Run again? (Y/N) n
Visualization:


Due Date:
Wednesday, October 20, 1999.
What To Turn In:
Turn in a 3.5" floppy disk and a printout containing your source code (in lecture).