设计一个类Circle,用来表示二维平面中的圆
(2014-04-27 06:07:28)
标签:
it |
分类: OC作业 |
---------------------- ASP.Net+Unity开发、.Net培训、期待与您交流! ----------------------
#import
#import
// 点
@interface Point2D : NSObject
{
}
// x值的getter和setter
- (void)setX:(double)x;
- (double)x;
// y值的getter和setter
- (void)setY:(double)y;
- (double)y;
// 同时设置x和y
- (void)setX:(double)x andY:(double)y;
// 计算跟其他点的距离
- (double)distanceWithOther:(Point2D *)other;
// 计算两个点之间的距离
+ (double)distanceBetweenPoint1:(Point2D *)p1 andPoint2:(Point2D *)p2;
@end
@implementation Point2D
// x值的getter和setter
- (void)setX:(double)x
{
}
- (double)x
{
}
// y值的getter和setter
- (void)setY:(double)y
{
}
- (double)y
{
}
// 同时设置x和y
- (void)setX:(double)x andY:(double)y
{
[self setX:x];
[self setY:y];
}
// 计算跟其他点的距离
- (double)distanceWithOther:(Point2D *)other
{
}
// 计算两个点之间的距离
+ (double)distanceBetweenPoint1:(Point2D *)p1 andPoint2:(Point2D *)p2
{
}
@end
// 圆
@interface Circle : NSObject
{
}
// 半径的getter和setter
- (void)setRadius:(double)radius;
- (double)radius;
// 圆心的getter和setter
- (void)setPoint:(Point2D *)point;
- (Point2D *)point;
// 跟其他圆是否重叠(重叠返回YES,否则返回NO)
- (BOOL)isInteractWithOther:(Circle *)other;
// 判断两个圆是否重叠(重叠返回YES,否则返回NO)
+ (BOOL)isInteractBetweenCircle1
@end
@implementation Circle
// 半径的getter和setter
- (void)setRadius:(double)radius
{
}
- (double)radius
{
}
// 圆心的getter和setter
- (void)setPoint:(Point2D *)point
{
}
- (Point2D *)point
{
}
// 跟其他圆是否重叠(重叠返回YES,否则返回NO)
- (BOOL)isInteractWithOther:(Circle *)other
{
}
// 判断两个圆是否重叠(重叠返回YES,否则返回NO)
+ (BOOL)isInteractBetweenCircle1
{
}
@end
int main()
{
}
---------------------- ASP.Net+Unity开发、.Net培训、期待与您交流! ----------------------