Skip to content
Open
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
97 changes: 87 additions & 10 deletions TestAssessment/TestViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,70 @@ @implementation TestViewController
This method should return any positive NSInteger
(hint: cannot be 0)
*/
- (void)shouldReturnAPositiveNSInteger {

}
- (NSInteger)shouldReturnAPositiveNSInteger {
NSInteger num = 1;
return num;
}


/*
This method should return any negative CGFloat
(hint: cannot be 0)
*/
- (void)shouldReturnANegativeCGFloat {
- (float)shouldReturnANegativeCGFloat {
float a = -4.2;
float x = -3.2;
float negSum = a + x;
return negSum;


}

/*
This method should return a falsy boolean
Falsey: Something which evaluates to FALSE.
*/
- (void)shouldReturnAFalseyBool {
- (BOOL)shouldReturnAFalseyBool {
int a = 1;
int b = 2;

if (a + b = int) {
return FALSE;
}


}

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



NSString *alphabet = @"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
NSString *character = [alphabet substringFromIndex:[alphabet length] - 5];
NSLog(@"%@", character);

}


}

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

int sum = 0;
int x = 99;
for (int i = 1; i <= x; i++) {
int answer = sum + i;

NSLog(@"The sum of 1 added to all the numbers leading up to 99 is %d", answer);

}
return 0;
}

Expand All @@ -57,6 +90,8 @@ Given a c array (int[]) and a count, return the sum of the numbers within the ar
(eg. arr[0] + arr[1] ...)
*/
- (NSInteger)shouldReturnSumOfArrayValues:(int *)arr withSize:(int)count {

NSMutableArray
return 0;
}

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

char *what = "aionkljajvqlkjaml";
while (int i = 0 <= 10) {
what = i;
return i;


}



return '\0';
}

/*
This method should return the sum of aNumber + bNumber
*/
- (NSInteger)sumOfAnInteger:(NSInteger)aNumber andAnotherInteger:(NSInteger)bNumber {
NSInteger sum = aNumber + bNumber;
NSLog(@"%ld", (long)sum);
return 0;
}

Expand All @@ -82,13 +130,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) {
return YES;
}else{
return NO;
}
}

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

Expand All @@ -97,21 +151,33 @@ - (BOOL)isMultipleOfFive:(NSInteger)aNumber {
*/
- (BOOL)returnYesIfThisNumberIsOdd:(NSInteger)aNumber
andThisNumberIsEven:(NSInteger)bNumber {
return NO;

if (aNumber && bNumber % 2) {
return YES;
}else{
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 @"";
Person
person.name;
return @"name";//????
}

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

person.name = "Ada Lovelace";

//crap


}

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

}

/*
Expand All @@ -149,6 +216,16 @@ - (void)makePersonStandUp:(Person *)person {
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/
*/
- (NSArray *)createAndReturnNSArray {

NSString *coolPeople = @"ericalexbob";
NSString *coolDogs = @"milocooperspike";
NSString *coolCats = @"paperbuddhabud";
NSString *idk = @"jellybeans";
NSString *rock = @"kryptonite";
NSString *thePresident = @"BarackObama";

NSArray *stuff [ *coolPeople, *cool ]

return [[NSArray alloc] init];
}

Expand Down