Challenge
Your challenge is to add two new properties to your TemperatureConverter class from the last video tutorial:
-
location: A string that stores the location of the temperature readings
-
averageDegreesFarenheit: The average of the values passed to
degreesFarenheitToCelsius
so far
Inside your App Delegate, replace the application:didFinishLaunchingWithOptions:
method with this to test it:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
TemperatureConverter *converter = [[TemperatureConverter alloc] init];
converter.location = @"Virginia";
for (int i = 60; i <= 80; i+= 10) {
float degreesCelsius = [converter degreesFarenheitToCelsius:i];
NSLog(@"%0.2f degrees farenheit = %0.2f degrees celsius",
(float)i, degreesCelsius);
}
NSLog(@"Average degrees farenheit in %@: %0.2f", converter.location, converter.averageDegreesFarenheit);
return YES;
}
Download demo code
Download challenge starter project
Download solution
Helpful links