Skip to content

Exercise_16_08 #11

@csv77

Description

@csv77

Hi,
I have found a little mistake in Exercise_16_08. The method isIntersect() examines wether the two circles intersect or not. This method gives true also in case of one containing the other. The method can correct like this:
public boolean isIntersect() {
double distance = Math.sqrt(Math.pow(c1.getCenterX() - c2.getCenterX(), 2) +
Math.pow(c1.getCenterY() - c2.getCenterY(), 2));
return distance < c1.getRadius() + c2.getRadius() &&
distance > Math.max(c1.getRadius(), c2.getRadius()) - Math.min(c1.getRadius(), c2.getRadius());
}
Bye,
Csaba

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions