Question: Submit Lab3.java, Lab3.jar, screen shots of results, and this word file (completed version) for lab3. Problem Description: Define the Circle2D class that contains: one Point2D.Double

Submit Lab3.java, Lab3.jar, screen shots of results, and this word file (completed version) for lab3.

Problem Description:

Define the Circle2D class that contains:

  • one Point2D.Double data field named center that specifies the center of the circle with get and set methods.
  • A data field radius with a get method.
  • A default constructor that creates a default circle with (0, 0) for (x, y) of the center and 1 for radius.
  • A constructor that creates a circle with the specified x, y, and radius, where (x,y) is the center cordinates.
  • A constructor that creates a circle with the specified p and radius, where p is the center as Point2D.Double.
  • A method area() that returns the area of the circle.
  • A method perimeter() that returns the perimeter of the circle.
  • A method contains (double x, double y) that returns true if the specified point (x, y) is inside this circle. See Figure 10.14(a).
  • A method contains (Point2D.Double p) that returns true if the specified point p is inside this circle.
  • A method contains (Circle2D circle) that returns true if the specified circle is inside this circle. See Figure 10.14(b).
  • A method overlaps (Circle2D circle) that returns true if the specified circle overlaps with this circle. See Figure 10.14(c).
  • A method disjoints (Circle2D circle) that returns true if the specified circle does not intersect with this circle. See Figure 10.14(d).
  • A method tangent (Circle2D circle) that returns true if the specified circle and this circle tangent to each other. See Figure 10.14(d).

Submit Lab3.java, Lab3.jar, screen shots of results, and this word file (completed

  1. Draw the UML class diagram for the Circle2D class.

Complete following UML class diagram.

Circle2D

- center: Point2D.Double

- radius : double

+ Circle2D()

+ Circle2D(double x, double y, double r)

+ Circle2D(Point2D.Double p, double r)

  1. Implement the Circle2D class according to the UML.

Copy and Paste Source Code here. Format your code using Courier 10pts.

class Circle2D {

// Implement your class here

}

3. Testing

public class Lab3 {

public static void main(String[] args) {

System.out.println("Lab3: Your name");

Circle2D c1 = new Circle2D(2, 2, 5.5);

System.out.println("Area of c1 is: " + c1.area());

System.out.println("Perimeter of c1 is: " + c1.perimeter());

System.out.println("c1.contains(3, 3) is: " + c1.contains(3, 3));

System.out.println(("c1.contains(new Circle2D(4, 5, 10.5)) is: " +

c1.contains(new Circle2D(4, 5, 10.5)));

//add code to test the rest of the methods of Circle2D.

}

}

4. Copy your running results as text here:

( ) Ol (a) (b) (c) (d) Figure 10.14 Job (e)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!