Skip to content

Instantly share code, notes, and snippets.

@carbamide
Created January 17, 2014 15:57
Show Gist options
  • Save carbamide/8475818 to your computer and use it in GitHub Desktop.
Save carbamide/8475818 to your computer and use it in GitHub Desktop.
Age of Josh command line Foundation app
#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