Question: Show me the steps to Write a method called centroid that takes one formal parameter of type OUPolygon and returns the centroid of the actual
Show me the steps to
Write a method called centroid that takes one formal parameter of type OUPolygon and returns the centroid of the actual parameter as a Point.
Use a foreach loop to access each of three different polygons points.
Accumulate the total of the x values and the total of the y values of the polygons points.
divide each by the number of points to find their means.
Return a Point object whose x and y coordinates are integer approximations of the mean x and y values in the polygon poly
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
