Improving the Circle class (Due 04 Apr 2004)

The Circle class that we discussed had only one attribute, the radius. However, we may also want to know where the Circle is located. We want to specify the coordinates of the center of the Circle. We will define a helper class called Point that has the information about the location.
class Point
{
  public double x;
  public double y;

  public Point ()
  { ... }

  public Point ( double xPos, double yPos )
  { ... }

  public double dist ( Point aPoint )
  { ... }
}

The attributes for Point are declared public for convenience. You do not need accessor and mutator methods. The method dist() gives the distance between this Point and aPoint.

The definition for Circle now is expanded. The format looks as follows:

class Circle
{
  private double radius;
  private Point center;

  public Circle ()
  { ... }

  public Circle ( double aRadius, double xPos, double yPos )
  { ... }

  public Circle ( double aRadius, Point aCenter )
  { ... }

  public double getRadius ()
  { ... }

  public void setRadius ( double aRadius )
  { ... }

  public Point getCenter ()
  { ... }

  public void setCenter ( Point aCenter )
  { ... }

  public double calcCircumference ()
  { ... }

  public double calcArea ()
  { ... }

  public boolean isInside ( Point p )
  { ... }

  public boolean isInside ( Circle c )
  { ... }

  public boolean doesIntersect ( Circle c )
  { ... }
}
This class has three constructors, two accessors and two mutators. The method calcCircumference() calculates the circumference and returns the value. The method calcArea() calculates the area and returns the value. The method isInside ( Point p ) returns true if the Point p is inside this Circle. The method isInside ( Circle c ) returns true if the Circle c is completely inside this Circle. The method doesIntersect() returns true if the Circle c intersects this Circle.

You need to test the functionality of the Circle class that you have created. Write a driver TestCircle to test all of the methods. The format of this class will be

public class TestCircle
{
  // Create object aCircle with radius 2.0 at location ( 5.0, 6.0)
     ...

  // Calculate the circumference and the area of aCircle and
  // print the results.
     ...

  // Create object bCircle using the default constructor
     ...

  // Assign bCircle a radius and location so that it is completely
  // within aCircle. Test this fact using the method isInside() and
  // print the result.
     ...

  // Move the location of the bCircle so that it is outside aCircle.
  // Test and print this result.
     ...

  // Create object dCircle with a given radius and center so that it
  // intersects aCircle. Test and print the result.
     ...

  // Mode the dCircle so that it does not intersect aCircle. Test and
  // print the result.
     ...
}

The file that you will be turning in will be called TestCircle.java. You will follow the standard Java coding convention that I have appended below. The file will have a header of the following form:

/*
  File: TestCircle.java

  Description:

  Student Name:

  Student UT EID:

  Course Name: CS 303E

  Unique Number: 

  TA:

  Date Created:

  Date Last Modified:

*/

You will follow the standard Java Coding Conventions. You can either view the HTML page or download the PDF or Postscript and print it out. There is a modification that I would like to make to the standard coding conventions. Please align the opening and closing braces vertically so that you can easily make out the blocks of code.

Use the turnin program to submit your TestCircle.java file. The TAs should receive your work by 5 PM, Sunday, 04 April 2004.