Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is C++ grphics. P1. Lines Write a program that uses five Line objects to draw a pentagon, like this. (Hint: draw it first on

This is C++ grphics. P1. Lines Write a program that uses five Line objects to draw a pentagon, like this. (Hint: draw it first on grid paper to choose values for vertices) P2. Moving graphical objects Generate five circles with center (0,0) and radius 1, 2, 3, 4, and 5. Then use the move() method of the Circle class to move (and then redraw with cwin <<) the circles all tangent at a common point, like this: P3. Drawing Wider Lines Modify the line drawing program mousedraw.cpp (repeated below) to draw 2 parallel lines for each mouse click. The lines should be separated by about 0.25 units, but try different separations to see the effect. (Hint: use the move() method). //draw points and lines into the cwin window where the user clicks. //mousedraw.cpp #include "ccc_win.h" //include files contain the drawing code #include ccc_msw.cpp //and definitions of the classes (objects) #include ccc_shap.cpp int ccc_win_main() { int i; Point p(0,0), pold; //pold to save previous coordinates for (i = 0;; i++) // draw circles or points or lines { pold = p; //save previous coordinates to draw line from p = cwin.get_mouse("click mouse to draw lines"); cwin << p; //show the point (optional) if (i>0) // don't draw bogus line to 1st point cwin << Line(pold, p); //connect points with lines } return 0; } 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 main() program to call those new functions, and print out the area at one of the rectangle corners, and the perimeter at the other corner. 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 4th point the user clicks, and re-drawing it there 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(Rectangle a[], int Numrectangles, double dx, double dy) that will move all the rectangles in the array. Hint: this function is very short, just one for() loop containing one line. void plot_r_array(Rectangle a[], int Numrectangles) that will draw all the rectangles in the array to cwin. Hint: this is also very short, just one for() loop containing one line.Write a test program to demonstrate moving and plotting 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_2

Step: 3

blur-text-image_3

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

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions