first, second), and can make the circles visible or invisible. You can prove this by doing the following:
moveUp, moveDown etc.) so you can tell them apart. Different colors would help, too.eraseCircles on your CircleDrawer object and notice that they both disappear. Run drawCircles and both will reappear.drawCircles method so that it only draws circles with radii greater than 20 and less than 50. (You can use the getDiameter method in the Circle class to find out how large a circle is — do not change the Circle class!) In other words, instead of always calling makeVisible on both circles, check to see if the radius is in the right range before drawing.
Remember that you can use the Boolean and operator (&&) to build more complex tests. Also, when testing your modified method, don't forget that you can still invoke changeSize on the circles you've created on the object workbench.
addCircle method so that it returns a reference to the circle that's being eliminated. This is a little tricky since the return statement needs to be at the end of the method, but if you're not careful, you'll have lost track of the circle by then. Verify that your modified works! For example, you could make the returned circle visible again, or just use the object inspector to verify that it has the same attributes as the old "first" circle did. (When you call the method from BlueJ, you can click the "Get" button in the method result box to put the returned object on the desktop.)
replaceSmallest that takes a
Circle as a parameter, just like addCircle does. The new
method will replace one of the current circles with the one passed to
the method but, unlike addCircle, we'll get rid of the
smaller of first and second. We need
to respect seniority, though: If first is the smaller,
we'll promote second to take its place and add the new
circle in second place. If second is the
smaller, we'll just replace it with the new circle. In the case of a
tie, replace second.
Hint: This is pretty easy if you remember that you can call the original addCircle method from within replaceSmallest.