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
119 changes: 103 additions & 16 deletions TestAssessment/TestViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,54 @@ @implementation TestViewController
This method should return any negative NSInteger
(hint: cannot be 0)
*/
- (void)shouldReturnANegativeNSInteger {
- (NSInteger)shouldReturnANegativeNSInteger {

NSInteger number=-5;

return number;
}

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

CGFloat yaMamma= 4.5;

return yaMamma;
}

/*
This method should return a truthy boolean
Truthy: Something which evaluates to TRUE.
*/
- (void)shouldReturnAPositiveBool {
- (BOOL)shouldReturnAPositiveBool {

BOOL accioPositivity=YES;

return accioPositivity;
}

/*
This method should return any single char from c - l
*/
- (void)shouldReturnACharCtoL {

- (char)shouldReturnACharCtoL {
char letter= 'e';
return letter;
}

/*
This method should return the product of all numbers from
This method should return the sum of all numbers from
0 - 1000 using a loop (eg. 1 + 2 + 3 + ... + 998 + 999)
*/
- (NSInteger)shouldReturnSumOf0To1000 {
return 0;
NSInteger sum= 0;

for(NSInteger counter=0;counter<=1000;counter++){
sum=sum+counter;
}
return sum;
}

/*
Expand All @@ -60,7 +75,14 @@ Given a c array (int[]) and a count, return the average of the numbers within th
*/
- (NSInteger)shouldReturnAverageOfArrayValues :(int *)arr
withSize:(int)count {
return 0;
int sum=0;
for(int counter=0;counter<=count-1; counter++){

sum=sum+arr[counter];
}

int average= sum/count;
return average;
}

/*
Expand All @@ -70,7 +92,14 @@ Provided a C string (array of chars), return the character
(hint: assume there will be a char after g)
*/
- (char)shouldReturnCharAfterG:(char *)str {
return '\0';

int counter=0;

while (str[counter]!='g') {
counter++;
}

return str[counter+1];
}

/*
Expand All @@ -79,52 +108,88 @@ - (char)shouldReturnCharAfterG:(char *)str {
*/
- (NSInteger)productOfAnInteger:(NSInteger)aNumber
andAnotherInteger:(NSInteger)bNumber {
return 0.0;



NSInteger product=aNumber*bNumber;
return product;
}


/*
This method should return a YES if aNumber is Even
*/
- (BOOL)isEven:(NSInteger)aNumber {



if (aNumber%2==0) {
return YES;
}
else{
return NO;
}
}

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

if (aNumber%10==0) {
return YES;
}
else{
return NO;
}
}

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


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



/*
This method should return the model of the Car
(hint: command + click on the class name to see what methods are available)
*/
- (NSString *)shouldReturnCarModel:(Car *)car {
return @"";

NSString* nameOfModel= [car model];

return nameOfModel;
}

/*
This method should change the model of the car to "Firebird"
*/
- (void)changeCarModelToFirebird:(Car *)car {

[car setModel:@"Firebird"];

}

/*
This method should ask the car to drive 4 miles and then return
the car's current fuel level
*/
- (CGFloat)tellCarToDrive4MilesAndReturnFuelLevel:(Car *)car {
return 0.0;

[car drive:4];
float currentFuelLevel=[car fuelLevel];
return currentFuelLevel;
}

/*
Expand All @@ -133,13 +198,35 @@ - (CGFloat)tellCarToDrive4MilesAndReturnFuelLevel:(Car *)car {
2) Set the model to "Honda Pilot" WATCH YOUR SPELLING
3) Drive the car 6 miles
4) Return the car
/n
*/
- (Car *)createAndReturnANewCar {
return [[Car alloc] init];

Car* newCar= [[Car alloc] init];
[newCar setModel:@"Honda Pilot"];
[newCar drive:6];

return newCar;
}

- (int)returnSumOfAllItemsGreaterThan100:(int *)arr withSize:(int)size {
return 0;

int overOneHundred=0;
int counter=0;

while(counter<=size-1){
if(arr[counter]>=100){
overOneHundred=overOneHundred+arr[counter];
}
else{
counter++;
continue;
}
counter++;
}


return overOneHundred;
}

@end