From 16ce9e5a310964dc28c665a0685907c32bb8cafe Mon Sep 17 00:00:00 2001 From: Christella Date: Tue, 30 Jun 2015 21:59:21 -0400 Subject: [PATCH] Im finished --- .DS_Store | Bin 0 -> 6148 bytes TestAssessment/TestViewController.m | 81 +++++++++++++++++++++++----- 2 files changed, 67 insertions(+), 14 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..8e8372cfdfef91c30ec596ecabd789f053dd482c GIT binary patch literal 6148 zcmeHKT}s115dOASsQA*yKJE#G-XNBEf_eZU5k-s%nu3qHgg5XIUPHWyNAQ~;N=x-Y z1(7lnX1?9Y%qIISWHJEKVpY$9DS!!8aCAiTiO7A?9T~Z2Oia4QDIR!Ts@(|>$3J91 z&TfWtJ+mI0=hx78haM+*M1>YL=N;}jy1BiYFRQlcY(G!WKUt$`%d%ee74Z7 99; } /* This method should return a single char from a - z */ -- (void)shouldReturnACharAtoZ { +- (char)shouldReturnACharAtoZ { + + return 'c'; } /* @@ -49,15 +56,31 @@ - (void)shouldReturnACharAtoZ { 0 - 99 using a loop (. 1 + 2 + 3 + ... + 98 + 99) */ - (NSInteger)shouldReturnSumOf0To100 { - return 0; -} + + NSInteger sum = 0; + for( int i = 1; i <= 100; i++) { + if(i % 1 == 0) { + sum += i; + } + + + } + return sum;} + + + + /* Given a c array (int[]) and a count, return the sum of the numbers within the arr (eg. arr[0] + arr[1] ...) */ - (NSInteger)shouldReturnSumOfArrayValues:(int *)arr withSize:(int)count { - return 0; + + int sumOfArr [] = {40, 20, 10, 5, 2}; + NSInteger sumOfArrcount = sumOfArr[0] + sumOfArr[1] + sumOfArr[2] + sumOfArr[3] + sumOfArr[4]; + + return sumOfArrcount; } /* @@ -67,6 +90,8 @@ Provided a C string (array of chars), return the character (hint: while loop) */ - (char)shouldReturnCharBeforeQ:(char *)str { + + return '\0'; } @@ -74,7 +99,12 @@ - (char)shouldReturnCharBeforeQ:(char *)str { This method should return the sum of aNumber + bNumber */ - (NSInteger)sumOfAnInteger:(NSInteger)aNumber andAnotherInteger:(NSInteger)bNumber { - return 0; + + + + NSInteger sumOfAnInteger = aNumber + bNumber; + + return sumOfAnInteger; } @@ -82,14 +112,19 @@ - (NSInteger)sumOfAnInteger:(NSInteger)aNumber andAnotherInteger:(NSInteger)bNum This method should return a YES if aNumber is odd */ - (BOOL)isOdd:(NSInteger)aNumber { - return NO; + + + if (aNumber % 2 != 0) return YES; + else return NO; } /* This method should return YES if aNumber is a multiple of 5 */ - (BOOL)isMultipleOfFive:(NSInteger)aNumber { - return NO; + if (aNumber % 5 == 0) return YES; + else return NO; + } /* @@ -97,7 +132,9 @@ - (BOOL)isMultipleOfFive:(NSInteger)aNumber { */ - (BOOL)returnYesIfThisNumberIsOdd:(NSInteger)aNumber andThisNumberIsEven:(NSInteger)bNumber { - return NO; + + if (aNumber % 2 != 0) return YES; + else return NO; } /* @@ -105,7 +142,10 @@ - (BOOL)returnYesIfThisNumberIsOdd:(NSInteger)aNumber parameter (hint: command + click on class name to jump to the interface. */ - (NSString *)shouldReturnPersonsName:(Person *)person { - return @""; + + [person setName:@"kathy"]; + + return @"kathy"; } /* @@ -113,6 +153,8 @@ - (NSString *)shouldReturnPersonsName:(Person *)person { */ - (void)changePersonsNameToAdaLovelace:(Person *)person { + + [person setName:@"Ada Lovelace"]; } /* @@ -122,9 +164,17 @@ - (void)changePersonsNameToAdaLovelace:(Person *)person { 3) Set the person's age to 1823 */ - (Person *)createAndReturnPersonWithSomeProperties { - return [[Person alloc] init]; + + Person *santa = [[Person alloc] init]; + [santa setName:@"Santa Clause"]; + [santa setAge: 1823]; + + return santa; } + + + /* This method provides you an instance of Chair as a parameter 1) Create an instance of Person @@ -133,6 +183,9 @@ - (Person *)createAndReturnPersonWithSomeProperties { */ - (void)makePersonSitInChair:(Chair *)chair { + Person *joe = [[Person alloc]init]; + + [joe sitInChair: chair]; } @@ -141,7 +194,7 @@ - (void)makePersonSitInChair:(Chair *)chair { Send a message to this Person object telling it to stand up */ - (void)makePersonStandUp:(Person *)person { - + [person standUp]; } /*