Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

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

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

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions

Question

Explain the different types of Mergers.

Answered: 1 week ago

Question

What is dividend payout ratio ?

Answered: 1 week ago