Is it possible to use the getP1() and get P2() methods of the circle class to calculate the smallest and largest x/y value for the sprinkle?

+1 vote

Yes.

getP1() and getP2() return the points on the opposite corners of the "bounding square" for a circle. Since they are methods of the Circle class, then they need to be called from a Circle object. The drawSprinkle function has as one of its parameters donut, a Circle object. Then the methods can be called as donut.getP1() and donut.getP2(). Those method return a Point object. Using methods of the Point class, the x and y values of those points can be accessed. Those x and y value can be used to set the limits on the size of the x and y values for the sprinkle's center which are generated using random.randrange(..........)