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
6 changes: 3 additions & 3 deletions TestAssessment/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="ufC-wZ-h7g">
<objects>
<viewController id="vXZ-lx-hvc" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
<viewController id="vXZ-lx-hvc" customClass="ViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="jyV-Pf-zRb"/>
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
Expand Down
100 changes: 84 additions & 16 deletions TestAssessment/TestViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,46 +18,60 @@ @implementation TestViewController
This method should return any positive NSInteger
(hint: cannot be 0)
*/
- (void)shouldReturnAPositiveNSInteger {

- (NSInteger)shouldReturnAPositiveNSInteger {
NSInteger aPositiveInteger = 25;
return aPositiveInteger;
}

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

}

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

- (BOOL)shouldReturnAFalseyBool {
BOOL quit = 0;
return quit;
}

/*
This method should return a single char from a - z
*/
- (void)shouldReturnACharAtoZ {
- (char)shouldReturnACharAtoZ {
char userInput = 'a';
return userInput;
}

/*
This method should return the sum of all numbers from
0 - 99 using a loop (. 1 + 2 + 3 + ... + 98 + 99)
*/
- (NSInteger)shouldReturnSumOf0To100 {
return 0;
NSInteger sum = 0;
for (NSInteger i = 0; i < 100; i++) {
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;
NSInteger resultArray = 0;
for (NSInteger i = 0; i < count; i++) {
resultArray += arr[i];
}
return resultArray;
}

/*
Expand All @@ -67,51 +81,90 @@ Provided a C string (array of chars), return the character
(hint: while loop)
*/
- (char)shouldReturnCharBeforeQ:(char *)str {
return '\0';

BOOL notB4Q = YES;
char beforeQ = '\0';

while (notB4Q) {
for (int i = 0; i < 17; i++) {
if (str[i] == 'q') {
beforeQ = str[i-1];
notB4Q = NO;
}
}
}
return beforeQ;
}

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

NSInteger result = aNumber + bNumber;


return result;
}


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

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

BOOL multipleOfFive = NO;

if (aNumber % 5 == 0) {
multipleOfFive = YES;
} else {
multipleOfFive = NO;
}

return multipleOfFive;
}

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

BOOL theyAreOddAndEven = 0;
if (!(aNumber % 2 == 0) && (bNumber % 2 == 0)) {
theyAreOddAndEven = YES;
} else {
theyAreOddAndEven = NO;
}
return theyAreOddAndEven;
}

/*
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 {
[person setName:@"Ada Lovelace"];

}

Expand All @@ -122,7 +175,13 @@ - (void)changePersonsNameToAdaLovelace:(Person *)person {
3) Set the person's age to 1823
*/
- (Person *)createAndReturnPersonWithSomeProperties {
return [[Person alloc] init];

Person *jay = [[Person alloc] init];

[jay setName:@"Santa Clause"];
[jay setAge: 1823];

return jay;
}

/*
Expand All @@ -133,6 +192,8 @@ - (Person *)createAndReturnPersonWithSomeProperties {

*/
- (void)makePersonSitInChair:(Chair *)chair {
Person *jay = [[Person alloc]init];
[jay sitInChair: chair];

}

Expand All @@ -141,6 +202,8 @@ - (void)makePersonSitInChair:(Chair *)chair {
Send a message to this Person object telling it to stand up
*/
- (void)makePersonStandUp:(Person *)person {
[person standUp];


}

Expand All @@ -149,7 +212,10 @@ - (void)makePersonStandUp:(Person *)person {
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/
*/
- (NSArray *)createAndReturnNSArray {
return [[NSArray alloc] init];

NSArray *myArray = [NSArray arrayWithObjects:@"apple", @"google", @"hello", @"cool", @"jay", @"mike", nil];

return myArray;
}

// BONUS
Expand All @@ -161,6 +227,8 @@ - (NSArray *)createAndReturnNSArray {
- (void)changeValueOfIndexFourInArray:(NSMutableArray *)arr
toPersonsName:(Person *)person {



}

// BONUS
Expand Down