Advertisement
Guest User

Untitled

a guest
Jul 6th, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #import <Foundation/Foundation.h>
  2.  
  3. // define out struct Person
  4. struct Person {
  5. int age;
  6. BOOL isAccompanied;
  7. BOOL hasSwag;
  8. int money;
  9. };
  10.  
  11. int main(int argc, const char * argv[]) {
  12. @autoreleasepool {
  13.  
  14. // Justin
  15. struct Person justin;
  16. justin.age = 18;
  17. justin.isAccompanied = YES;
  18. justin.hasSwag = NO;
  19. justin.money = 4;
  20.  
  21. // Carl
  22. struct Person carl;
  23. carl.age = 21;
  24. carl.isAccompanied = YES;
  25. carl.hasSwag = YES;
  26. carl.money = 4000;
  27.  
  28. // rules
  29. int minAge = 21;
  30. int buyoff = 50;
  31.  
  32. // Boolean logic
  33. if (carl.age >= minAge && !carl.isAccompanied) {
  34. NSLog(@"You can't play this game");
  35. } else if (!carl.hasSwag) {
  36. if (carl.money >= buyoff) {
  37. NSLog(@"welcome");
  38. } else {
  39. NSLog(@"You can't play this game");
  40. }
  41. } else {
  42. NSLog(@"welcome");
  43. }
  44.  
  45. }
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement