Question: Write a class called polygon which can initialise regular 1 Two - Dimensional ( 2 D ) polygons, and translate them in the + /

Write a class called polygon which can initialise regular1 Two-Dimensional (2D) polygons, and
translate them in the +/-x and +/-y directions (or both x and y). It should also be able to rotate
them by any number of degrees about any point. Come up with your own names for all class
members except N and r. The following members must be included in your class, exactly as
instructed, and must serve a meaningful purpose in your program:
Private members:
o Member of type std::string, to store a user-defined polygon name (e.g.t_1)
Note: the user-defined polygon name must always take the form l_i where
l is a letter, i an integer; this also applies in ProgramB.
o Member (r) of type double, to store the radius.
1Regular means that all the polygons internal angles are the same, and all edges are of identical length.
4
o Member (N) of type integer, to store the number of vertices.
o Member of type std::vector, to store the x-coordinates of the polygon vertices.
o Member of type std::vector, to store the y-coordinates of the polygon vertices.
o Member function which prints any objects name, number of vertices and coordinates
(as a coordinate pair for each vertex) on screen using the standard output stream. The
printed output must take the following exact form (although obviously the user
defined polygon name, the coordinates and the number of coordinate pairs will vary).
All numerical printed output should be rounded to 5 decimal places:
t_1=polygon((1.73205,-1),(0,2),(-1.73205,-1))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!