#import <Foundation/Foundation.h>
// the interface
@interface Car : NSObject {
int wheels;
int doors;
}
-(void) setNumWheels: (int) w;
-(void) setNumDoors: (int) d;
-(void) print;
@end
// the implementation
@implementation Car
-(void) seNumWheels: (int) w{
wheels = w;
}
-(void) setNumDoors: (int) d{
doors = d;
}
-(void) print {
NSLog (@"My car has %i wheels and %i doors.", doors, wheels);
}
@end
// the program
int main(int argc, const char * argv[])
{
@autoreleasepool {
Car *myCar;
myCar = [Car alloc];
myCar = [myCar init];
[myCar seNumWheels:4 ];
[myCar setNumDoors:4];
[myCar print];
}
}