Answer:

Different values need to be stored in the object's x and yvariables.

Data Access Method

Here is the Circle class with two new methods. The setPosition() method will be used to change the location of a circle. The setRadius() method will be used to change the radius of a circle. Such methods are called access methods because they access the data of an object. Well-designed classes allow access to their data only through access methods. To enforce this, the variables of a class are often made private.

class Circle
{
  // variables
  private int x, y, radius;

  // constructors
  public Circle()
  { x = 0; y = 0; radius = 0; }

  public Circle( int x, int y, int radius )
  { this.x = x;  this.y = y;  this.radius = radius; }

  // methods
  void draw( Graphics gr )
  {
    int ulX = x-radius ; // X of upper left corner of rectangle
    int ulY = y-radius ; // Y of upper left corner of rectangle
    gr.drawOval( ulX, ulY, 2*radius, 2*radius );
  }

  // change the center of the circle to a new X and Y
  void setPosition( int newX, int newY )
  {
     ;

     ;
  }

  // chage the radius of the circle
  void setRadius( int newR )
  {

     ;
  }

}

QUESTION 9:

Complete the methods by filling in the blanks.