www.pudn.com > property_test_1.zip > Car.m, change:2008-08-03,size:959b


#import "Car.h"

@implementation Car

@synthesize name = appellation;
@synthesize engine;

- (id) init
{
    if (self = [super init]) {

		self.name = @"Car";
        tires = [[NSMutableArray alloc] init];

        int i;
        for (i = 0; i < 4; i++) {
            [tires addObject: [NSNull null]];
        }
    }

    return (self);

} // init


- (void) dealloc
{
	self.name = nil;
    [tires release];
    [engine release];

    [super dealloc];

} // dealloc


- (void) setTire: (Tire *) tire
         atIndex: (int) index
{
    [tires replaceObjectAtIndex: index
           withObject: tire];

} // setTire:atIndex:


- (Tire *) tireAtIndex: (int) index
{
    Tire *tire;
    tire = [tires objectAtIndex: index];

    return (tire);

} // tireAtIndex:


- (void) print
{
	NSLog (@"%@ has:", self.name);
    int i;
    for (i = 0; i < 4; i++) {
        NSLog (@"%@", [self tireAtIndex: i]);
    }

    NSLog (@"%@", engine);

} // print

@end // Car