Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.m
- // CarParts
- //
- // Created by Carter Burn on 3/30/12.
- // Copyright (c) 2012 __MyCompanyName__. All rights reserved.
- //
- #import <Foundation/Foundation.h>
- @interface Tire : NSObject
- @end // Tire Int
- @implementation Tire
- - (NSString *) description
- {
- return (@"I am a tire, I last awhile.");
- }
- @end // Tire Imp
- @interface Engine : NSObject
- @end // Engine Int
- @implementation Engine
- - (NSString *) description
- {
- return (@"I am an engine. Vroom!!");
- }
- @end // Engine Imp.
- @interface Car : NSObject {
- @private
- Engine * engine;
- Tire * tire[4];
- }
- - (void) print;
- @end // Car Int
- @implementation Car
- - (id) init
- {
- if (self = [super init]) {
- engine = [Engine new];
- tire[0] = [Tire new];
- tire[1] = [Tire new];
- tire[2] = [Tire new];
- tire[3] = [Tire new];
- }
- return self;
- }
- - (void) print
- {
- NSLog(@"%@", engine);
- NSLog(@"%@", tire[0]);
- NSLog(@"%@", tire[1]);
- NSLog(@"%@", tire[2]);
- NSLog(@"%@", tire[3]);
- }
- @end
- int main (int argc, const char * argv[])
- {
- Car *car;
- car = [Car new];
- [car print];
- return 0;
- }
Add Comment
Please, Sign In to add comment