Created
January 17, 2014 15:57
-
-
Save carbamide/8475818 to your computer and use it in GitHub Desktop.
Age of Josh command line Foundation app
This file contains 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
#import <Foundation/Foundation.h> | |
int ageOfJosh(int realAge) | |
{ | |
int statedAge = 29; | |
if (realAge > 29) { | |
return statedAge; | |
} | |
return realAge; | |
} | |
void death() | |
{ | |
NSLog(@"Josh Died"); | |
abort(); | |
} | |
int main(int argc, char *argv[]) { | |
@autoreleasepool { | |
for (int i = 0; i < 101; i++) { | |
int deathPossibility = arc4random_uniform(100); | |
if (deathPossibility == 10) { | |
death(); | |
break; | |
} | |
NSLog(@"Josh is %i %@ old - real age - %i", ageOfJosh(i), i == 1 ? @"year" : @"years", i); | |
if (i == 100) { | |
NSLog(@"Josh died of old age."); | |
} | |
} | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment