This is a University assignment, we do need to do the following exercise at C++
There are 6 types of shapes with 4 sides:
Square, rectangle, trapezoid, closed shape, parallelogram and undefined.
Define struct to a single point (x,y) and on this struct basis define struct to a shape’s side.
Now define a new struct with four sides called StShape that will contain besides the sides a string that will contain the shape’s name (out of the six).
Read from the file c: [login to view URL] the all shapes data (untill 10 shapes).
In each line there are 16 integer numbers which every 4 numbers define one side.
(every 2 numbers are the points).
Define an array of struct StShape and fill it with the shapes data.
You need to do these functions:
1. function that receives array of 4 sides and reveals which type of shape they represent. The function need to give back struct of StShape with the sides data and the shape name.
2. function that receives array of StShape and it’s size and sort the shapes with bubble sort according to their type by this order: closed shape , parallelogram, rectangle, Square, trapezoid and undefined in the end. (use strcmp).
3. function that receives StShape and prints it’s data. With this function you need to show the array after the bubble sort.
Ex:
-2 -2 -2 1 2 1 2 4 -2 1 2 4 -2 -2 2 1 -------- parallelogram
2 -2 5 1 -4 -1 1 4 1 4 5 1 2 -2 -4 –1 --------- trapezoid
remarks:
1. if one shape is defined for more than one shape than define it by whats coming first in the bubble order.
2. cannot assume the sides are parallel to the x and y lines.
3. if two sides are connecting, it is the point of the shape.
Hi! I have a lot of experience in this type of problems. I can provide you a fully commented code in less than 1 day after you choose me.
Regards,
Cloe