A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 李烨 中级黑马   /  2014-4-14 13:59  /  701 人查看  /  1 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

  1. @interface Circle : NSObject
  2. {
  3.     // 半径
  4.     double _radius;
  5.     // 圆心
  6.     Point2D * _point;
  7. }

  8. //判断跟其他圆是否重叠
  9. //返回值是BOOL类型的 一般方法名都已is开头
  10. - (BOOL)isInteractWithOther:(Circle *)other;

  11. //判断两个圆是否重叠
  12. + (BOOL)isInteractBerweenCircle1:circle1 andCircle2:circle2;


  13. // _radius geter setter
  14. - (void)setRadius:(double)radius;
  15. - (double)radius;

  16. //_point setter getter
  17. - (void)setPoint:(Point2D *)point;
  18. - (Point2D *)point;
  19. @end

  20. @implementation Circle
  21. //_radius setter getter
  22. - (void)setRadius:(double)radius
  23. {
  24.     _radius = radius;
  25. }
  26. - (double)radius
  27. {
  28.     return _radius;
  29. }

  30. //_point setter getter
  31. - (void)setPoint:(Point2D *)point
  32. {
  33.     _point = point;
  34. }
  35. - (Point2D *)point
  36. {
  37.     return _point;
  38. }

  39. //判断跟其他圆是否重叠
  40. //返回值是BOOL类型的 一般方法名都已is开头
  41. - (BOOL)isInteractWithOther:(Circle *)other
  42. {
  43.     //如果两个圆心的距离<两个圆的半径,重叠
  44.     double distance = [[self point] distanceWithOther:[other point]];
  45.     double radiusSum =[self radius] + [other radius];
  46.     return distance < radiusSum;
  47. }

  48. //判断两个圆是否重叠
  49. + (BOOL)isInteractBerweenCircle1:circle1 andCircle2:circle2
  50. {
  51.     return [circle1 isInteractWithOther:circle2];
  52. }
  53. @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里面不是声明了么   ,哪个不算么

1 个回复

倒序浏览
方法声明:
+ (BOOL)isInteractBerweenCircle1:(Circle *)circle1 andCircle2:(Circle *)circle2;
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马