Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import <Foundation/Foundation.h>
- // define out struct Person
- struct Person {
- int age;
- BOOL isAccompanied;
- BOOL hasSwag;
- int money;
- };
- int main(int argc, const char * argv[]) {
- @autoreleasepool {
- // Justin
- struct Person justin;
- justin.age = 18;
- justin.isAccompanied = YES;
- justin.hasSwag = NO;
- justin.money = 4;
- // Carl
- struct Person carl;
- carl.age = 21;
- carl.isAccompanied = YES;
- carl.hasSwag = YES;
- carl.money = 4000;
- // rules
- int minAge = 21;
- int buyoff = 50;
- // Boolean logic
- if (carl.age >= minAge && !carl.isAccompanied) {
- NSLog(@"You can't play this game");
- } else if (!carl.hasSwag) {
- if (carl.money >= buyoff) {
- NSLog(@"welcome");
- } else {
- NSLog(@"You can't play this game");
- }
- } else {
- NSLog(@"welcome");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement