Created
September 9, 2011 02:10
-
-
Save ejknapp/1205329 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment