# Creating your own class

posted 5 years ago

Hi;

I am creating my own class in my program. I am suppose to create a big circle that has another circle inside, another one outside, and finally another one intersecting it. I have a circletester, and a drawing panel. So far this is what I have for my program:

I am suppose to create a public boolean inside(Circle c2) to test if the circle is inside the circle and I am having trouble creating that. If anyone can help I will appreciate. Thanks, A

I am creating my own class in my program. I am suppose to create a big circle that has another circle inside, another one outside, and finally another one intersecting it. I have a circletester, and a drawing panel. So far this is what I have for my program:

I am suppose to create a public boolean inside(Circle c2) to test if the circle is inside the circle and I am having trouble creating that. If anyone can help I will appreciate. Thanks, A

Campbell Ritchie

Marshal

Posts: 52565

119

posted 5 years ago

Your method should have one parameter: test whether the circle passed is inside the current circle. But I wouldn't try that at first. Comment out the inside method and try to write this methodNow you will have to work out whether a point (~~the squaw on the hippopotamus is equal to the sons of the squaws on the other two hides~~. Once you have that working, you can calculate how far inside the circle that point (

You don't need programming just at the moment. You need a pencil and paper. By the way: there are methods in the java.lang.Math class which can work out some of the calculations for Pythagoras.

*xx*,*yy*) is inside your circle or outside. You will also have to decide what to do if the point is exactly on your circumference. And to do that you will have to use Pythagoras' theorem:*xx*,*yy*) is. If the distance inside is greater (or ≥) the radius of the inside circle, then the whole of that circle is inside.You don't need programming just at the moment. You need a pencil and paper. By the way: there are methods in the java.lang.Math class which can work out some of the calculations for Pythagoras.

posted 5 years ago

Thanks for the respond Campbell. I think I got it. I have another question though, if I want to create 100 random Circle object, each with a random location within the panel and a random radius from 1 to 20 with a loop how can I do that? I know that I need to use an array to do this. But I don't want any circle that intersect the big circle. This is the code that I have so far: