Exercise10_11.java:4: error: class Circle2D is public, should be declared in a file named Circle2D.java

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

can you fix this code for me this is the error i am getting 

Exercise10_11.java:4: error: class Circle2D is public, should be declared in a file named Circle2D.java
public class Circle2D {

// Implement Circle2D class
public class Circle2D {
    /**  Data fields */
    private double x; 
    private double y; 
    private double radius;

    /** Create a default Circle2D with 
    *  (0,0) for (x,y) and 1 for radius */
    Circle2D() {
        this(0, 0, 1);
    }

    /** Create a Circle2D with specified x,y, and radius */
    Circle2D(double x, double y, double radius) {
        this.x = x;
        this.y = y;
        this.radius = radius;
    }

    /** Return x */
    public double getX() {
        return x;
    }

    /** Return y */
    public double getY() {
        return y;
    }

    /** Return radius */
    public double getRadius() {
        return radius;
    }

    /** Return the area of the circle */
    public double getArea() {
        return Math.PI * Math.pow(radius, 2);
    }

    /** Return the perimeter of the circle */
    public double getPerimeter() {
        return 2 * Math.PI * radius;
    }

    /** Return true if the specified point
    *   (x, y) is inside this circle     */
    public boolean contains(double x, double y) {
        return Math.sqrt(Math.pow(x - this.x, 2) + 
                 Math.pow(y - this.y, 2)) 
                 < radius;
    }

    /** Return true if the specified 
    *   circle is inside this circle */
    public boolean contains(Circle2D circle) {
        return Math.sqrt(Math.pow(circle.getX() - x, 2) + 
                 Math.pow(circle.getY() - y, 2)) 
                 <= Math.abs(radius - circle.getRadius());
    }

    /** Return true if the specified 
    *   circle overlaps with this circle */
    public boolean overlaps(Circle2D circle) {
        return Math.sqrt(Math.pow(circle.getX() - x, 2) + 
                 Math.pow(circle.getY() - y, 2)) 
                 <= radius + circle.getRadius();
    }
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education