Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.m
- // First
- //
- // Created by Eric Knapp on 9/8/11.
- // Copyright 2011 Madison Area Technical College. All rights reserved.
- //
- #import <Foundation/Foundation.h>
- #import "Car.h"
- int main (int argc, const char * argv[])
- {
- Car *car1 = [[Car alloc] init];
- car1.model = @"Accord";
- car1.year = 2000;
- //[car1 setModel:@"Accord"];
- // insert code here...
- NSLog(@"My car model is %@", car1.model);
- NSLog(@"model year: %@", [car1 modelYear]);
- return 0;
- }
- //
- // Car.m
- // First
- //
- // Created by Eric Knapp on 9/8/11.
- // Copyright 2011 Madison Area Technical College. All rights reserved.
- //
- #import "Car.h"
- @implementation Car
- @synthesize model = _model;
- @synthesize year = _year;
- - (id)init
- {
- self = [super init];
- if (self) {
- // Initialization code here.
- }
- return self;
- }
- -(NSString *)modelYear
- {
- NSString *modelYearString = [[NSString alloc]
- initWithFormat:@"model: %@, year: %d",
- self.model,
- self.year];
- return modelYearString;
- }
- @end
Add Comment
Please, Sign In to add comment