FJMonster.h//怪兽类
#import
FJUltraman;
/**定义一个怪兽类有名字和生命值*/
NSObject{
NSString *_name;
NSUInteger_hp;
}
+ (instancetype) monsterWithName:(NSString *)name hp:(NSUInteger)hp;
- (instancetype) initWithName:(NSString *) name hp:(NSUInteger)hp;
//怪兽攻击奥特曼
- (void) attack:(FJUltraman *) ultraman;
- (NSUInteger) hp;
- (void) setHp:(NSUInteger) hp;
- (NSString *) name;
FJMonster.m
#import"FJMonster.h"
#import"FJUltraman.h"
@implementationFJMonster
+ (instancetype) monsterWithName:(NSString *)name hp:(NSUInteger)hp{
return [[self alloc] initWithName:(NSString *)name hp:(NSUInteger)hp];
}
- (instancetype) initWithName:(NSString *)name hp:(NSUInteger)hp{
if (self = [super init]) {
_name =