Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7830061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:03:37+00:00 2026-06-02T11:03:37+00:00

here is my Java problem: My Circle class implements the Shape interface and thus

  • 0

here is my Java problem:

My Circle class implements the Shape interface and thus it must implement all the methods required. I have a problem with the method boolean contains(Rectangle2D r) that “Tests if the interior of the Shape entirely contains the specified Rectangle2D”. Now, Rectangle2D is an abstract class that does not provide (to the best of my poor knowledge) any method to get the coordinates of the corners of the rectangle. To be more precise: “The Rectangle2D class describes a rectangle defined by a location (x, y) and dimension (w x h). This class is only the abstract superclass for all objects that store a 2D rectangle. The actual storage representation of the coordinates is left to the subclass”.

So how can I solve this?

Please find below a part of my code:

public class Circle implements Shape
{
private double x, y, radius;

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

// Tests if the specified coordinates are inside the boundary of the Shape
public boolean contains(double x, double y)
{
    if (Math.pow(this.x-x, 2)+Math.pow(this.y-y, 2) < Math.pow(radius, 2))
    {
        return true;
    }
    else
    {
        return false;
    }
}

// Tests if the interior of the Shape entirely contains the specified rectangular area
public boolean contains(double x, double y, double w, double h)
{
    if (this.contains(x, y) && this.contains(x+w, y) && this.contains(x+w, y+h) && this.contains(x, y+h))
    {
        return true;
    }
    else
    {
        return false;
    }
}

// Tests if a specified Point2D is inside the boundary of the Shape
public boolean contains(Point2D p)
{
    if (this.contains(p.getX(), p.getY()))
    {
        return true;
    }
    else
    {
        return false;
    }
}

// Tests if the interior of the Shape entirely contains the specified Rectangle2D
public boolean contains(Rectangle2D r)
{
    // WHAT DO I DO HERE????
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T11:03:38+00:00Added an answer on June 2, 2026 at 11:03 am

    Rectangle2D inherits getMaxX, getMaxY, getMinX, getMinY from RectangularShape. So you can get the coords of the corners.

    http://docs.oracle.com/javase/1.4.2/docs/api/java/awt/geom/Rectangle2D.html

    See “Methods inherited from class java.awt.geom.RectangularShape”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all, I have a Java problem. For my senior research class, I'm pretty
I have a problem when setting a variable inside a Java class Here is
I have a problem with a specific java client library. Here is the situation:
I'm new here and kinda new to java. I've encountered a problem. I have
After reading topics here about Java synchronized methods, I've tried to implement it in
I'd have a question here considering java generics. I have a generic class called
I have a Java applet related problem and I would appreciate your help. Here's
I've read Head First Java, and I understand how OOP works. Here's my problem:
I just want to know where am i wrong here: import java.io.*; class Tokens{
I have this chess engine Rybka.exe, that i have to execute in java Here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.