Guest User

Untitled

a guest
Jul 18th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //  main.m
  3. //  CarParts
  4. //
  5. //  Created by Carter Burn on 3/30/12.
  6. //  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
  7. //
  8.  
  9. #import <Foundation/Foundation.h>
  10.  
  11. @interface Tire : NSObject
  12. @end // Tire Int
  13.  
  14. @implementation Tire
  15.  
  16. - (NSString *) description
  17. {
  18.     return (@"I am a tire, I last awhile.");
  19. }
  20.  
  21. @end // Tire Imp
  22.  
  23. @interface Engine : NSObject
  24. @end // Engine Int
  25.  
  26. @implementation Engine
  27.  
  28. - (NSString *) description
  29. {
  30.     return (@"I am an engine. Vroom!!");
  31. }
  32.  
  33. @end // Engine Imp.
  34.  
  35. @interface Car : NSObject {
  36. @private
  37.     Engine * engine;
  38.     Tire * tire[4];
  39. }
  40.  
  41. - (void) print;
  42.  
  43. @end // Car Int
  44.  
  45. @implementation Car
  46.  
  47. - (id) init
  48. {
  49.     if (self = [super init]) {
  50.         engine = [Engine new];
  51.         tire[0] = [Tire new];
  52.         tire[1] = [Tire new];
  53.         tire[2] = [Tire new];
  54.         tire[3] = [Tire new];
  55.     }
  56.     return self;
  57. }
  58.  
  59. - (void) print
  60. {
  61.     NSLog(@"%@", engine);
  62.    
  63.     NSLog(@"%@", tire[0]);
  64.     NSLog(@"%@", tire[1]);
  65.     NSLog(@"%@", tire[2]);
  66.     NSLog(@"%@", tire[3]);
  67. }
  68.  
  69. @end
  70.  
  71. int main (int argc, const char * argv[])
  72. {
  73.     Car *car;
  74.    
  75.     car = [Car new];
  76.     [car print];
  77.    
  78.     return 0;
  79. }
Add Comment
Please, Sign In to add comment