上传得图片看不清,上代码。
//圆得实现。
#import "Circle.h"
#import "Point2D.h"
@implementation Circle
- (BOOL)isInteractWithOther:(Circle *)other
{
Point2D *p1 = [self point];
Point2D *p2 = [other point];
double distance = [p1 distanceWithOther:p2];
double radiusSum = [self radius] + [other radius];
return radiusSum > distance;
}
+ (BOOL)isInteractBewteenCircle1:(Circle *)c1 andCircle2:(Circle *)c2
{
return [c1 isInteractWithOther:c2];
}
@end
//圆的声明
#import <Foundation/Foundation.h>
@interface Circle : NSObject
@property double radius;
@property Point2D* point;
- (BOOL)isInteractWithOther:(Circle *)other;
+ (BOOL)isInteractBewteenCircle1:(Circle *)c1 andCircle2:(Circle *)c2;
@end
//main函数
#import <Foundation/Foundation.h>
#import "Point2D.h"
#import "Circle.h"
int main()
{
Circle *c = [[Circle alloc] init];
c.radius = 4;
Point2D *p1 = [[Point2D alloc] init];
[p1 setX:10 andY:13];
[c setPoint:p1];
c.point = p1;
//double d1 = [Point2D distanceBewteenPoint1:p andPoint2:p2];
Circle *c1 = [[Circle alloc] init];
c1.radius = 2;
Point2D *p2 = [[Point2D alloc] init];
[p2 setX:13 andY:17];
c1.point = p2;
BOOL b1 = [p1 isInteractWithOther:p2];
//NSLog(@"%d",b1);
return 0;
报错unused variable"b1"
请大神看下错在那了。 |