Answered step by step
Verified Expert Solution
Question
1 Approved Answer
P4. Extending the Rectangle Class Create a project, copying the code from the Rectangle example above. Make sure it builds and runs. Then modify the
P4. Extending the Rectangle Class Create a project, copying the code from the Rectangle example above. Make sure it builds and runs. Then modify the Rectangle Class to include member accessor functions area () and perimeter () to return the area and perimeter of the rectangle. These should be declared as const functions. Modify the main0 program to call those new functions, and print out the area at one of the rectangle corners, and the perimeter at the other corner Demonstrate your program to your instructor: Instructor Signature: P5. Triangle Class Create a new class called Triangle, similar to the Rectangle class. Include a test program that draws a triangle for every 3 points the user clicks. The program should also test the move) function by moving the triangle to the 4 point the user clicks, and re-drawing it there Demonstrate your program to your instructor: Instructor Signature P6. Arrays of Objects Write another test program using the Rectangle class, that creates an array of 4 rectangles. The user will enter the rectangle corners by mouse-click, as before. Write 2 new functions that access the objects in the array. Note that these are NOT member functions of the class. just standalone functions: void move_r_array (Rectangl rectangles in the array. Hint: this function is very short, just one for) loop containing one line. le al, int Numrectangles, double dx, double dy) that will move all the r array (Rectangle atl, int Numrectangles) that will draw all the rectangles in the array to cwin. ine.Write a test program to demonstrate moving and plotting void plot_r Hint: this is also very short, just one for) loop containing one l groups of 4 rectangles. P4. Extending the Rectangle Class Create a project, copying the code from the Rectangle example above. Make sure it builds and runs. Then modify the Rectangle Class to include member accessor functions area () and perimeter () to return the area and perimeter of the rectangle. These should be declared as const functions. Modify the main0 program to call those new functions, and print out the area at one of the rectangle corners, and the perimeter at the other corner Demonstrate your program to your instructor: Instructor Signature: P5. Triangle Class Create a new class called Triangle, similar to the Rectangle class. Include a test program that draws a triangle for every 3 points the user clicks. The program should also test the move) function by moving the triangle to the 4 point the user clicks, and re-drawing it there Demonstrate your program to your instructor: Instructor Signature P6. Arrays of Objects Write another test program using the Rectangle class, that creates an array of 4 rectangles. The user will enter the rectangle corners by mouse-click, as before. Write 2 new functions that access the objects in the array. Note that these are NOT member functions of the class. just standalone functions: void move_r_array (Rectangl rectangles in the array. Hint: this function is very short, just one for) loop containing one line. le al, int Numrectangles, double dx, double dy) that will move all the r array (Rectangle atl, int Numrectangles) that will draw all the rectangles in the array to cwin. ine.Write a test program to demonstrate moving and plotting void plot_r Hint: this is also very short, just one for) loop containing one l groups of 4 rectangles
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started