Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment, you are asked to write a program that stores and manipulates a list of (at-most 1000) polygons. Each polygon must be stored

In this assignment, you are asked to write a program that stores and manipulates a list of (at-most 1000) polygons. Each polygon must be stored in a structure like this: typedef struct { int numberOfVertices; Direction shiftDirection; Vertex* vertexList; }Polygon; where Direction and Vertex are defined like this: typedef enum { NONE = 0, UP = 1, DOWN = 2, LEFT = 4, RIGHT = 8 }Direction; typedef struct { int x, y; }Vertex; 1 Program Input Commands There are five valid input commands: add x1y1x2y2 . . . xnyn: adds an n-gon with vertices located at coordinates (x1, y1), (x2, y2), . . . , (xn, yn) to the list of all polygons. The newly added polygon must have its shiftDirection set to NONE. summary: prints the programs list of polygons. For each polygon, you need to print the number of vertices and the x-y coordinates of the polygons centroid. To avoid the complications of calculating the centroid, you can assume that the x-coordinate (y-coordinate) of a polygon is equal to the average of x-coordinates (y-coordinates) of the polgyons vertices. 1 turn k x: updates the shiftDirection of polygon stored at index k of the programs list of polygons. The shiftDirection has to be updated based on the value of x that can be equal to one of the following strings: left right up down right-up or up-right left-up or up-left right-down or down-right left-down or down-left shift k s: updates the x-y coordinates of vertices of polygon stored at index k of the programs list of polygons. To update the vertices coordinates of a polygon, you need to check its shiftDirection. If the direction is NONE, then the shift command has no side effect. If the direction is RIGHT(LEFT), then s has to be added to(subtracted from) the x-coordinate of every vertex of the polygon. If the direction is UP(DOWN), then s has to be added to(subtracted from) the y-coordinate of every vertex of the polygon. If the direction is RIGHT and UP, then s has to be added to both the x-coordinate and y-coordinate of every vertex of the polygon. quit: ends the program 2 Submissions You need to submit a .zip file compressing the following files: the C source file(s) related to the assignment (.c files). the header files (.h files) A readme file clearly explaining what parts have/havent been implemented.image text in transcribedimage text in transcribed

COP-4338 System Programming Programming Assignment 4: FIU KF School of Computing & Info. Sciences In this assignment, you are asked to write a program that stores and manipulates a list of (at-most 1000) polygons. Each polygon must be stored in a structure like this: typedef struct { int numberOfVertices; Direction shift Direction; Vertex* vertexList; }Polygon; where Direction and Vertex are defined like this: typedef enum { NONE = 0, UP = 1, DOWN = 2, LEFT = 4, RIGHT = 8 }Direction; typedef struct { int x, y; }Vertex; 1 Program Input Commands There are five valid input commands: add 01410242 ... InYn: adds an n-gon with vertices located at coordinates (x1, y), (x2; y2), ..., (In, Yn) to the list of all polygons. The newly added polygon must have its shift Direction set to NONE. summary: prints the program's list of polygons. For each polygon, you need to print the number of vertices and the x-y coordinates of the polygon's centroid. To avoid the complications of calculating the centroid, you can assume that the x-coordinate (y-coordinate) of a polygon is equal to the average of x-coordinates (y-coordinates) of the polgyon's vertices. turn k x: updates the shiftDirection of polygon stored at index k of the program's list of polygons. The shiftDirection has to be updated based on the value of that can be equal to one of the following strings: left - right - up - down right-up or up-right left-up or up-left - right-down or down-right left-down or down-left shift k s: updates the x-y coordinates of vertices of polygon stored at index k of the program's list of polygons. To update the vertices' coordinates of a polygon, you need to check its shift Direction. If the direction is NONE, then the shift command has no side effect. If the direction is RIGHT(LEFT), then s has to be added to(subtracted from) the x-coordinate of every vertex of the polygon. If the direction is UP(DOWN), then s has to be added to(subtracted from the y-coordinate of every vertex of the polygon. If the direction is RIGHT and UP, then s has to be added to both the x-coordinate and y-coordinate of every vertex of the polygon. quit: ends the program 2 Submissions You need to submit a .zip file compressing the following files: the source file(s) related to the assignment (.c files). the header files (.h files) A readme file clearly explaining what parts have/haven't been implemented

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

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions