Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions TestAssessment/Person.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

@interface Person : NSObject


// declared methods
- (void)setName:(NSString *)name;
- (NSString *)name;

Expand Down
65 changes: 51 additions & 14 deletions TestAssessment/TestViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,59 @@ @implementation TestViewController
This method should return any positive NSInteger
(hint: cannot be 0)
*/
- (void)shouldReturnAPositiveNSInteger {

- (NSInteger)shouldReturnAPositiveNSInteger {
return 2;
}

/*
This method should return any negative CGFloat
(hint: cannot be 0)
*/
- (void)shouldReturnANegativeCGFloat {

- (CGFloat)shouldReturnANegativeCGFloat {
return -1.5;
}

/*
This method should return a falsy boolean
Falsey: Something which evaluates to FALSE.
*/
- (void)shouldReturnAFalseyBool {

- (BOOL)shouldReturnAFalseyBool {
if (2 > 3) {
BOOL yes = YES;
yes = 1;
} else {
return FALSE;
}

/*
This method should return a single char from a - z
*/
- (void)shouldReturnACharAtoZ {
- (char)shouldReturnACharAtoZ {
return "c";
}

/*
This method should return the sum of all numbers from
0 - 99 using a loop (. 1 + 2 + 3 + ... + 98 + 99)
*/
- (NSInteger)shouldReturnSumOf0To100 {
return 0;

int sum;
sum = 0; // reset our sum
int maxNumber = 99; // set our max constraint

for (int i = 0; i < maxNumber; i++) {
sum = 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;
}

Expand All @@ -67,52 +81,74 @@ Provided a C string (array of chars), return the character
(hint: while loop)
*/
- (char)shouldReturnCharBeforeQ:(char *)str {

while (

return '\0';
}

/*
This method should return the sum of aNumber + bNumber
*/
- (NSInteger)sumOfAnInteger:(NSInteger)aNumber andAnotherInteger:(NSInteger)bNumber {
return 0;

NSInteger = aNumber;
aNumber = 1;

NSInteger = bNumber;
bNumber = 2;

NSInteger c;
c = aNumber + bNumber;
return c;

return sum;
}


/*
This method should return a YES if aNumber is odd
*/
- (BOOL)isOdd:(NSInteger)aNumber {
if (
return NO;
}

/*
This method should return YES if aNumber is a multiple of 5
*/
- (BOOL)isMultipleOfFive:(NSInteger)aNumber {
return NO;
if (int i % 5) {
return YES;
}
}

/*
This method should return YES is aNumber is odd and bNumber is even
*/
- (BOOL)returnYesIfThisNumberIsOdd:(NSInteger)aNumber
andThisNumberIsEven:(NSInteger)bNumber {
return NO;
return YES;
}

/*
This method should return the name property of the person
parameter (hint: command + click on class name to jump to the interface.
*/
- (NSString *)shouldReturnPersonsName:(Person *)person {
return @"";
}
return [person name];
}

/*
This method should change the person name to "Ada Lovelace"
*/
- (void)changePersonsNameToAdaLovelace:(Person *)person {

- (void)setName:(NSString *)name {

Person *name = [[Person alloc]init];
[Person setName: [self name]];
name = "Ada Lovelace";
return name;
}

/*
Expand All @@ -123,6 +159,7 @@ - (void)changePersonsNameToAdaLovelace:(Person *)person {
*/
- (Person *)createAndReturnPersonWithSomeProperties {
return [[Person alloc] init];

}

/*
Expand Down