#import<Foundation/Foundation.h>
typedef enum {
ColorRed,
ColorGreen,
ColorGlack
} Color;
typedef enum {
SexWomen,
SexMan
} Sex;
@interface Dog :NSObject
{
@public
Color color;
int speed;
Sex sex;
double weight;
}
- (void)eat;
- (void)bark;
- (void)run;
- (BOOL)isSameColorWithOther:(Dog *)other;
- (int)compareSpeedWithOther:(Dog *)other;
@end
@implementation Dog
- (void)eat
{
weight+=0.5;
NSLog(@"吃完后的体重为:%f",weight);
}
- (void)bark
{
NSLog(@"颜色为:%d,速度为:%d,性别为:%d,体重为:%f",color,speed,sex,weight);
}
- (void)run
{
weight-=0.5;
NSLog(@"狗跑的速度为%dkm/h,跑完后的体重为:%f",speed,weight);
}
- (BOOL)isSameColorWithOther:(Dog *)other;
{
return color-other->color;
}
- (int)compareSpeedWithOther:(Dog *)other
{
return speed==other->speed;
}
@end
int main()
{
Dog *p=[Dog new];
[p bark];
[p eat];
[p eat];
return 0;
}
这段代码中,- (BOOL)isSameColorWithOther:(Dog *)other;
这句代码怎么解释啊?
|
|