- @interface Circle : NSObject
- {
- // 半径
- double _radius;
- // 圆心
- Point2D * _point;
- }
- //判断跟其他圆是否重叠
- //返回值是BOOL类型的 一般方法名都已is开头
- - (BOOL)isInteractWithOther:(Circle *)other;
- //判断两个圆是否重叠
- + (BOOL)isInteractBerweenCircle1:circle1 andCircle2:circle2;
- // _radius geter setter
- - (void)setRadius:(double)radius;
- - (double)radius;
- //_point setter getter
- - (void)setPoint:(Point2D *)point;
- - (Point2D *)point;
- @end
- @implementation Circle
- //_radius setter getter
- - (void)setRadius:(double)radius
- {
- _radius = radius;
- }
- - (double)radius
- {
- return _radius;
- }
- //_point setter getter
- - (void)setPoint:(Point2D *)point
- {
- _point = point;
- }
- - (Point2D *)point
- {
- return _point;
- }
- //判断跟其他圆是否重叠
- //返回值是BOOL类型的 一般方法名都已is开头
- - (BOOL)isInteractWithOther:(Circle *)other
- {
- //如果两个圆心的距离<两个圆的半径,重叠
- double distance = [[self point] distanceWithOther:[other point]];
- double radiusSum =[self radius] + [other radius];
- return distance < radiusSum;
- }
- //判断两个圆是否重叠
- + (BOOL)isInteractBerweenCircle1:circle1 andCircle2:circle2
- {
- return [circle1 isInteractWithOther:circle2];
- }
- @end
复制代码
***********************************************************************************************
大家看最后两个方法,我改成这样:
- (BOOL)isInteractWithOther:(Circle *)other
{
return [Circle * isInteractBerweenCircle1:self andCircle2:other];
}
+ (BOOL)isInteractBerweenCircle1:circle1 andCircle2:circle2
{
//如果两个圆心的距离<两个圆的半径,重叠
double distance = [[circle1 point] distanceWithOther:[circle2 point]];
double radiusSum =[circle1 radius] + [circle2 radius];
//
return distance < radiusSum;
}
在这里
return [Circle * isInteractBerweenCircle1:self andCircle2:other];
提示我isInteractBerweenCircle1andCirle2没声明,但是在@interface里面不是声明了么 ,哪个不算么
|
|