#import <Foundation/Foundation.h>
@interface HumanCannibal : NSObject {
NSString *stomach;
NSString *place;
}
- (void) feed: (NSString*) input;
- (void) move: (NSString*) input;
+ (void) classOnlyMethod;
@end
#import "HumanCannibal.h"
@implementation HumanCannibal
- (void) init {
[super init];
}
- (void) feed: (NSString*) input {
stomach = input;
}
- (void) move: (NSString*) input {
place = input;
}
- (NSString*) description {
return [NSString stringWithFormat: @"In %@, stomach contains %@", place, stomach];
}
+ (void) classOnlyMethod {
}
@end
#import "HumanCannibal.h"
int main(void) {
HumanCannibal *lector = [HumanCannibal new];
NSLog(@"%@", lector);
[lector feed: @"Zak"];
[lector move: @"New York"];
NSLog(@"%@", lector);
}
|