Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.


+4 votes

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?

asked in old_CSC201 by (8 points)

1 Answer

+1 vote


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(..........)

answered by (8 points)