diff --git a/Week1/APLOC2 Week 1/APLOC2 Week 1.xcodeproj/project.xcworkspace/xcuserdata/notmyemail.xcuserdatad/UserInterfaceState.xcuserstate b/Week1/APLOC2 Week 1/APLOC2 Week 1.xcodeproj/project.xcworkspace/xcuserdata/notmyemail.xcuserdatad/UserInterfaceState.xcuserstate index 399ce11..f045294 100644 Binary files a/Week1/APLOC2 Week 1/APLOC2 Week 1.xcodeproj/project.xcworkspace/xcuserdata/notmyemail.xcuserdatad/UserInterfaceState.xcuserstate and b/Week1/APLOC2 Week 1/APLOC2 Week 1.xcodeproj/project.xcworkspace/xcuserdata/notmyemail.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Week2/APLOCWeek2/APLOCWeek2.xcodeproj/project.pbxproj b/Week2/APLOCWeek2/APLOCWeek2.xcodeproj/project.pbxproj index e282fec..a578086 100644 --- a/Week2/APLOCWeek2/APLOCWeek2.xcodeproj/project.pbxproj +++ b/Week2/APLOCWeek2/APLOCWeek2.xcodeproj/project.pbxproj @@ -21,6 +21,11 @@ 65D407D016CD2D6F00FAE85B /* ViewController_iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 65D407CE16CD2D6F00FAE85B /* ViewController_iPad.xib */; }; 65D407D716CD4EF900FAE85B /* ViewController2.xib in Resources */ = {isa = PBXBuildFile; fileRef = 65D407D616CD4EF900FAE85B /* ViewController2.xib */; }; 65D407DA16CD572700FAE85B /* ViewController2.m in Sources */ = {isa = PBXBuildFile; fileRef = 65D407D916CD572700FAE85B /* ViewController2.m */; }; + 65D407DD16CDC19E00FAE85B /* baseEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = 65D407DC16CDC19E00FAE85B /* baseEvent.m */; }; + 65D407E016CDC5F400FAE85B /* swimEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = 65D407DF16CDC5F400FAE85B /* swimEvent.m */; }; + 65D407E316CDD16C00FAE85B /* bikeEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = 65D407E216CDD16B00FAE85B /* bikeEvent.m */; }; + 65D407E616CDD3CE00FAE85B /* runEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = 65D407E516CDD3CE00FAE85B /* runEvent.m */; }; + 65D407E916CDDA4300FAE85B /* eventFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = 65D407E816CDDA4300FAE85B /* eventFactory.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -44,6 +49,16 @@ 65D407D616CD4EF900FAE85B /* ViewController2.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ViewController2.xib; sourceTree = ""; }; 65D407D816CD572700FAE85B /* ViewController2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewController2.h; sourceTree = ""; }; 65D407D916CD572700FAE85B /* ViewController2.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewController2.m; sourceTree = ""; }; + 65D407DB16CDC19E00FAE85B /* baseEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = baseEvent.h; sourceTree = ""; }; + 65D407DC16CDC19E00FAE85B /* baseEvent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = baseEvent.m; sourceTree = ""; }; + 65D407DE16CDC5F400FAE85B /* swimEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = swimEvent.h; sourceTree = ""; }; + 65D407DF16CDC5F400FAE85B /* swimEvent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = swimEvent.m; sourceTree = ""; }; + 65D407E116CDD16B00FAE85B /* bikeEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bikeEvent.h; sourceTree = ""; }; + 65D407E216CDD16B00FAE85B /* bikeEvent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = bikeEvent.m; sourceTree = ""; }; + 65D407E416CDD3CE00FAE85B /* runEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = runEvent.h; sourceTree = ""; }; + 65D407E516CDD3CE00FAE85B /* runEvent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = runEvent.m; sourceTree = ""; }; + 65D407E716CDDA4300FAE85B /* eventFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = eventFactory.h; sourceTree = ""; }; + 65D407E816CDDA4300FAE85B /* eventFactory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = eventFactory.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -100,6 +115,16 @@ 65D407D616CD4EF900FAE85B /* ViewController2.xib */, 65D407D816CD572700FAE85B /* ViewController2.h */, 65D407D916CD572700FAE85B /* ViewController2.m */, + 65D407DB16CDC19E00FAE85B /* baseEvent.h */, + 65D407DC16CDC19E00FAE85B /* baseEvent.m */, + 65D407DE16CDC5F400FAE85B /* swimEvent.h */, + 65D407DF16CDC5F400FAE85B /* swimEvent.m */, + 65D407E116CDD16B00FAE85B /* bikeEvent.h */, + 65D407E216CDD16B00FAE85B /* bikeEvent.m */, + 65D407E416CDD3CE00FAE85B /* runEvent.h */, + 65D407E516CDD3CE00FAE85B /* runEvent.m */, + 65D407E716CDDA4300FAE85B /* eventFactory.h */, + 65D407E816CDDA4300FAE85B /* eventFactory.m */, ); path = APLOCWeek2; sourceTree = ""; @@ -190,6 +215,11 @@ 65D407C116CD2D6F00FAE85B /* AppDelegate.m in Sources */, 65D407CA16CD2D6F00FAE85B /* ViewController.m in Sources */, 65D407DA16CD572700FAE85B /* ViewController2.m in Sources */, + 65D407DD16CDC19E00FAE85B /* baseEvent.m in Sources */, + 65D407E016CDC5F400FAE85B /* swimEvent.m in Sources */, + 65D407E316CDD16C00FAE85B /* bikeEvent.m in Sources */, + 65D407E616CDD3CE00FAE85B /* runEvent.m in Sources */, + 65D407E916CDDA4300FAE85B /* eventFactory.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Week2/APLOCWeek2/APLOCWeek2.xcodeproj/project.xcworkspace/xcuserdata/notmyemail.xcuserdatad/UserInterfaceState.xcuserstate b/Week2/APLOCWeek2/APLOCWeek2.xcodeproj/project.xcworkspace/xcuserdata/notmyemail.xcuserdatad/UserInterfaceState.xcuserstate index a5b741f..dceb159 100644 Binary files a/Week2/APLOCWeek2/APLOCWeek2.xcodeproj/project.xcworkspace/xcuserdata/notmyemail.xcuserdatad/UserInterfaceState.xcuserstate and b/Week2/APLOCWeek2/APLOCWeek2.xcodeproj/project.xcworkspace/xcuserdata/notmyemail.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Week2/APLOCWeek2/APLOCWeek2/ViewController.h b/Week2/APLOCWeek2/APLOCWeek2/ViewController.h index 8530307..5821857 100644 --- a/Week2/APLOCWeek2/APLOCWeek2/ViewController.h +++ b/Week2/APLOCWeek2/APLOCWeek2/ViewController.h @@ -7,15 +7,16 @@ // #import +#import "eventFactory.h" @interface ViewController : UIViewController { IBOutlet UISegmentedControl *segmentControl; IBOutlet UIStepper *stepperControl; - IBOutlet UIButton *cricketButton; - IBOutlet UIButton *butterflyButton; - IBOutlet UIButton *antButton; - IBOutlet UIButton *executeButton; + IBOutlet UIButton *swimButton; + IBOutlet UIButton *bikeButton; + IBOutlet UIButton *runButton; + IBOutlet UIButton *competeButton; IBOutlet UITextField *textBox; } @@ -27,4 +28,6 @@ -(IBAction)onClassButtonClick:(id)sender; +-(IBAction)onCompeteClick:(id)sender; + @end diff --git a/Week2/APLOCWeek2/APLOCWeek2/ViewController.m b/Week2/APLOCWeek2/APLOCWeek2/ViewController.m index b17092e..d3c74f1 100644 --- a/Week2/APLOCWeek2/APLOCWeek2/ViewController.m +++ b/Week2/APLOCWeek2/APLOCWeek2/ViewController.m @@ -15,35 +15,47 @@ @implementation ViewController +-(IBAction)onCompeteClick:(id)sender +{ + swimEvent *newSwimEvent = (swimEvent*)[eventFactory createNewEvent:SWIM]; + [newSwimEvent setWaterTemp: 70]; + + textBox.text = [NSString stringWithFormat:@"Event Time of %.2f Minutes", [newSwimEvent calculateEventTime]]; +} + + -(IBAction)onClassButtonClick:(id)sender { UIButton *classButton = (UIButton*)sender; if (classButton.tag == 0) { - textBox.text = @"Cricket"; + textBox.text = @"Swim 1 mile"; stepperControl.enabled = TRUE; + stepperControl.maximumValue = 3; classButton.enabled = FALSE; - antButton.enabled = TRUE; - butterflyButton.enabled = TRUE; + runButton.enabled = TRUE; + bikeButton.enabled = TRUE; stepperControl.value = 0; } else if (classButton.tag == 1) { - textBox.text = @"Butterfly"; + textBox.text = @"Bike 1 mile"; stepperControl.enabled = TRUE; + stepperControl.maximumValue = 120; classButton.enabled = FALSE; - antButton.enabled = TRUE; - cricketButton.enabled = TRUE; + runButton.enabled = TRUE; + swimButton.enabled = TRUE; stepperControl.value = 0; } else if (classButton.tag == 2) { - textBox.text = @"Ant"; + textBox.text = @"Run 1 mile"; stepperControl.enabled = TRUE; + stepperControl.maximumValue = 26; classButton.enabled = FALSE; - cricketButton.enabled = TRUE; - butterflyButton.enabled = TRUE; + swimButton.enabled = TRUE; + bikeButton.enabled = TRUE; stepperControl.value = 0; } @@ -58,28 +70,28 @@ if (currentValue == 1) { - if (cricketButton.enabled == FALSE) + if (swimButton.enabled == FALSE) { - textBox.text = @"Cricket"; + textBox.text = @"Swim 1 mile"; } - else if (butterflyButton.enabled == FALSE) + else if (bikeButton.enabled == FALSE) { - textBox.text = @"Butterfly"; + textBox.text = @"Bike 1 mile"; } - else textBox.text = @"Ant"; + else textBox.text = @"Run 1 mile"; } else { - if (cricketButton.enabled == FALSE) + if (swimButton.enabled == FALSE) { - textBox.text = [NSString stringWithFormat:@"%d Crickets", currentValue]; + textBox.text = [NSString stringWithFormat:@"Swim %d miles", currentValue]; } - else if (butterflyButton.enabled == FALSE) + else if (bikeButton.enabled == FALSE) { - textBox.text = [NSString stringWithFormat:@"%d Butterflies", currentValue]; + textBox.text = [NSString stringWithFormat:@"Bike %d miles", currentValue]; } - else textBox.text = [NSString stringWithFormat:@"%d Ants", currentValue]; + else textBox.text = [NSString stringWithFormat:@"Run %d miles", currentValue]; } } diff --git a/Week2/APLOCWeek2/APLOCWeek2/baseEvent.h b/Week2/APLOCWeek2/APLOCWeek2/baseEvent.h new file mode 100644 index 0000000..eb6b1eb --- /dev/null +++ b/Week2/APLOCWeek2/APLOCWeek2/baseEvent.h @@ -0,0 +1,35 @@ +// +// baseEvent.h +// APLOCWeek2 +// +// Created by Brent Marohnic on 2/14/13. +// Copyright (c) 2013 Brent Marohnic. All rights reserved. +// + +#import + +@interface baseEvent : NSObject +{ + int eventEnum; +} + +typedef enum +{ + SWIM, + BIKE, + RUN +} eventEnum; + +// common data members for all events + +@property NSString *eventName; +@property int eventDistance; +@property int eventTimeInMinutes; + +// initialize +-(id)init; + +// calculate event time +-(float)calculateEventTime; + +@end diff --git a/Week2/APLOCWeek2/APLOCWeek2/baseEvent.m b/Week2/APLOCWeek2/APLOCWeek2/baseEvent.m new file mode 100644 index 0000000..84481c9 --- /dev/null +++ b/Week2/APLOCWeek2/APLOCWeek2/baseEvent.m @@ -0,0 +1,36 @@ +// +// baseEvent.m +// APLOCWeek2 +// +// Created by Brent Marohnic on 2/14/13. +// Copyright (c) 2013 Brent Marohnic. All rights reserved. +// + +#import "baseEvent.h" + +@implementation baseEvent + +// allow the compiler to automatically genenate get and set methods for the event properties +@synthesize eventDistance, eventName, eventTimeInMinutes; + +// initilize the base event +-(id)init +{ + self = [super init]; + if (self != nil) + { + [self setEventName: nil]; + [self setEventDistance: 0]; + [self setEventTimeInMinutes:0]; + } + return self; +} + +// calculate event time +-(float)calculateEventTime +{ + NSLog(@"This will be overridden"); + return 1.0; +} + +@end diff --git a/Week2/APLOCWeek2/APLOCWeek2/bikeEvent.h b/Week2/APLOCWeek2/APLOCWeek2/bikeEvent.h new file mode 100644 index 0000000..374209c --- /dev/null +++ b/Week2/APLOCWeek2/APLOCWeek2/bikeEvent.h @@ -0,0 +1,16 @@ +// +// bikeEvent.h +// APLOCWeek2 +// +// Created by Brent Marohnic on 2/14/13. +// Copyright (c) 2013 Brent Marohnic. All rights reserved. +// + +#import "baseEvent.h" + +@interface bikeEvent : baseEvent + +// event specific data members used to calculate event time +@property int elevationInFeet; + +@end diff --git a/Week2/APLOCWeek2/APLOCWeek2/bikeEvent.m b/Week2/APLOCWeek2/APLOCWeek2/bikeEvent.m new file mode 100644 index 0000000..30c1efc --- /dev/null +++ b/Week2/APLOCWeek2/APLOCWeek2/bikeEvent.m @@ -0,0 +1,47 @@ +// +// bikeEvent.m +// APLOCWeek2 +// +// Created by Brent Marohnic on 2/14/13. +// Copyright (c) 2013 Brent Marohnic. All rights reserved. +// + +#import "bikeEvent.h" + +@implementation bikeEvent + +@synthesize elevationInFeet, eventDistance, eventName; + +// set unique data members from within INIT + +-(id)init +{ + self = [super init]; + if (self != nil) + { + [self setElevationInFeet:5500]; + [self setEventDistance:120]; + [self setEventName:@"Biking"]; + } + return self; +} + +// override the base event method +// handicap equals the (absolute value of (optimum elevation - current elevation) * 0.01) * (absolute value of (optimum elevation - current elevation) +// distanceHandicap equals the best training time for one mile * (distance * 1.05) + +-(float)calculateEventTime +{ + float handicap; + float distanceHandicap; + + handicap = abs(25 - elevationInFeet) * 0.01 * abs(25 - elevationInFeet); + distanceHandicap = 2 * (eventDistance * 1.05); + + [self setEventTimeInMinutes:(handicap + distanceHandicap)]; + + return self.eventTimeInMinutes; +} + + +@end diff --git a/Week2/APLOCWeek2/APLOCWeek2/en.lproj/ViewController_iPhone.xib b/Week2/APLOCWeek2/APLOCWeek2/en.lproj/ViewController_iPhone.xib index 8b5280f..0958a9e 100644 --- a/Week2/APLOCWeek2/APLOCWeek2/en.lproj/ViewController_iPhone.xib +++ b/Week2/APLOCWeek2/APLOCWeek2/en.lproj/ViewController_iPhone.xib @@ -39,12 +39,13 @@ 274 - + 292 {{0, 519}, {320, 30}} + _NS:9 NO IBCocoaTouchFramework @@ -76,13 +77,13 @@ - + 292 {{247, 0}, {73, 33}} - + _NS:9 NO IBCocoaTouchFramework @@ -90,7 +91,7 @@ 0 1 Info - + 3 MQA @@ -98,27 +99,27 @@ 1 MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA - + 3 MC41AA - + 2 15 - + Helvetica-Bold 15 16 - + 292 - {{122, 80}, {178, 30}} + {{20, 80}, {280, 30}} - + _NS:9 NO YES @@ -127,11 +128,11 @@ 0 3 - Select Insect + Select Event 3 MAA - + 2 @@ -150,13 +151,13 @@ 16 - + 268 - {{20, 82}, {94, 27}} + {{109, 118}, {94, 27}} - + _NS:9 NO YES @@ -169,36 +170,36 @@ 1 10 - + 292 {{20, 164}, {86, 44}} - + _NS:9 NO IBCocoaTouchFramework 0 0 1 - Cricket - + Swim + 1 MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA - - - + + + - + 292 - {{208, 164}, {86, 44}} + {{207, 164}, {85, 44}} - + _NS:9 NO 2 @@ -206,23 +207,23 @@ 0 0 1 - Ant - + Run + 1 MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA - - - + + + - + 292 - {{114, 164}, {86, 44}} + {{114, 164}, {85, 44}} - + _NS:9 NO 1 @@ -230,47 +231,47 @@ 0 0 1 - Butterfly - + Bike + 1 MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA - - - + + + - + 292 {{20, 416}, {280, 44}} - + _NS:9 NO IBCocoaTouchFramework 0 0 1 - Execute - + Compete + 1 MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA - - + + {{0, 20}, {320, 548}} - + 3 MC43NQA - + NO @@ -308,7 +309,7 @@ segmentControl - + 15 @@ -316,54 +317,54 @@ stepperControl - + 85 - - - antButton - - - - 86 - - - - butterflyButton - - - - 87 - - - - cricketButton - - - - 88 - - - - executeButton - - - - 89 - textBox - + 93 + + + swimButton + + + + 105 + + + + runButton + + + + 106 + + + + bikeButton + + + + 107 + + + + competeButton + + + + 108 + onChange: - + 13 @@ -372,7 +373,7 @@ onClick: - + 7 @@ -381,7 +382,7 @@ onStepChange: - + 13 @@ -390,7 +391,7 @@ onClassButtonClick: - + 7 @@ -399,7 +400,7 @@ onClassButtonClick: - + 7 @@ -408,12 +409,21 @@ onClassButtonClick: - + 7 91 + + + onCompeteClick: + + + 7 + + 109 + @@ -438,8 +448,8 @@ 6 - - + + 6 0 @@ -454,8 +464,8 @@ 29 3 - - + + 5 0 @@ -470,8 +480,8 @@ 29 3 - - + + 4 0 @@ -486,8 +496,8 @@ 29 3 - - + + 5 0 @@ -502,11 +512,11 @@ 29 3 - + 6 0 - + 6 1 @@ -518,11 +528,11 @@ 29 3 - + 4 0 - + 4 1 @@ -534,11 +544,11 @@ 9 3 - - + + 5 0 - + 6 1 @@ -550,11 +560,11 @@ 24 3 - - + + 11 0 - + 11 1 @@ -566,8 +576,8 @@ 24 2 - - + + 3 0 @@ -582,8 +592,8 @@ 29 3 - - + + 6 0 @@ -598,11 +608,27 @@ 29 3 - - + + + 9 + 0 + + 9 + 1 + + 0.0 + + 1000 + + 6 + 24 + 2 + + + 11 0 - + 11 1 @@ -614,11 +640,11 @@ 24 2 - - + + 5 0 - + 6 1 @@ -630,8 +656,8 @@ 24 3 - - + + 3 0 @@ -646,8 +672,8 @@ 9 3 - - + + 5 0 @@ -662,28 +688,12 @@ 29 3 - - - 10 + + + 3 0 - - 10 - 1 - - 0.0 - - 1000 - - 6 - 24 - 2 - - - - 5 - 0 - - 6 + + 4 1 8 @@ -694,8 +704,24 @@ 24 3 - - + + + 5 + 0 + + 5 + 1 + + 20 + + 1000 + + 8 + 29 + 3 + + + 3 0 @@ -710,11 +736,11 @@ 9 3 - + 6 0 - + 6 1 @@ -726,59 +752,43 @@ 29 3 - - - 5 - 0 - - 5 - 1 - - 20 - - 1000 - - 8 - 29 - 3 - - - - - - - - - + + + + + + + + 8 - + 14 - + 13 - + 11 - + 18 - + - - + + 8 0 @@ -788,13 +798,13 @@ 32 1000 - + 3 9 1 - - + + 7 0 @@ -804,7 +814,7 @@ 73 1000 - + 3 9 1 @@ -814,89 +824,52 @@ 21 - + 22 - + 24 - - + + 26 - - + + 28 - + 36 - + 37 - + 38 - - - - - 7 - 0 - - 0 - 1 - - 94 - - 1000 - - 3 - 9 - 1 - - - - - - 42 - - - - - 43 - - - - - 44 - - - - - 45 - + + 46 - + - - + + 7 0 @@ -906,7 +879,7 @@ 86 1000 - + 3 9 1 @@ -916,30 +889,30 @@ 49 - + 50 - + 51 - + - - + + 7 0 0 1 - 86 + 85 1000 - + 3 9 1 @@ -949,58 +922,96 @@ 54 - + + + + + 7 + 0 + + 0 + 1 + + 85 + + 1000 + + 3 + 9 + 1 + + 65 - + - - 69 - - - - - 70 - - - 72 - - - - - 73 - + 74 - + 81 - + 83 - + 78 - + 66 - + + + + + 100 + + + + + 102 + + + + + 103 + + + + + 104 + + + + + 110 + + + + + 111 + + + + + 113 + @@ -1010,13 +1021,20 @@ com.apple.InterfaceBuilder.IBCocoaTouchPlugin UIResponder com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -1028,56 +1046,49 @@ com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - - - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin - + com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -1092,7 +1103,7 @@ - 97 + 113 @@ -1111,6 +1122,7 @@ id id id + id id @@ -1126,35 +1138,35 @@ onClick: id + + onCompeteClick: + id + onStepChange: id - UIButton - UIButton - UIButton - UIButton + UIButton + UIButton + UIButton UISegmentedControl UIStepper + UIButton UITextField - - antButton + + bikeButton UIButton - - butterflyButton + + competeButton UIButton - - cricketButton - UIButton - - - executeButton + + runButton UIButton @@ -1165,6 +1177,10 @@ stepperControl UIStepper + + swimButton + UIButton + textBox UITextField diff --git a/Week2/APLOCWeek2/APLOCWeek2/eventFactory.h b/Week2/APLOCWeek2/APLOCWeek2/eventFactory.h new file mode 100644 index 0000000..9a13c95 --- /dev/null +++ b/Week2/APLOCWeek2/APLOCWeek2/eventFactory.h @@ -0,0 +1,19 @@ +// +// eventFactory.h +// APLOCWeek2 +// +// Created by Brent Marohnic on 2/14/13. +// Copyright (c) 2013 Brent Marohnic. All rights reserved. +// + +#import +#import "baseEvent.h" +#import "swimEvent.h" +#import "bikeEvent.h" +#import "runEvent.h" + +@interface eventFactory : NSObject + ++(baseEvent *)createNewEvent:(int)eventType; + +@end diff --git a/Week2/APLOCWeek2/APLOCWeek2/eventFactory.m b/Week2/APLOCWeek2/APLOCWeek2/eventFactory.m new file mode 100644 index 0000000..58a9060 --- /dev/null +++ b/Week2/APLOCWeek2/APLOCWeek2/eventFactory.m @@ -0,0 +1,31 @@ +// +// eventFactory.m +// APLOCWeek2 +// +// Created by Brent Marohnic on 2/14/13. +// Copyright (c) 2013 Brent Marohnic. All rights reserved. +// + +#import "eventFactory.h" + + +@implementation eventFactory + ++(baseEvent *)createNewEvent:(int)eventType +{ + if (eventType == SWIM) + { + return [[swimEvent alloc] init]; + } + else if (eventType == BIKE) + { + return [[bikeEvent alloc] init]; + } + else if (eventType == RUN) + { + return [[runEvent alloc] init]; + } + else return nil; +} + +@end diff --git a/Week2/APLOCWeek2/APLOCWeek2/runEvent.h b/Week2/APLOCWeek2/APLOCWeek2/runEvent.h new file mode 100644 index 0000000..7a139f5 --- /dev/null +++ b/Week2/APLOCWeek2/APLOCWeek2/runEvent.h @@ -0,0 +1,27 @@ +// +// runEvent.h +// APLOCWeek2 +// +// Created by Brent Marohnic on 2/14/13. +// Copyright (c) 2013 Brent Marohnic. All rights reserved. +// + +#import "baseEvent.h" + +@interface runEvent : baseEvent +{ + int terrainEnum; +} + +typedef enum +{ + PAVEDESTREETS, + MIXEDSURFACE, + CROSSCOUNTRY +} terrainEnum; + +// event specific data members used to calculate event time + +@property int terrainType; + +@end diff --git a/Week2/APLOCWeek2/APLOCWeek2/runEvent.m b/Week2/APLOCWeek2/APLOCWeek2/runEvent.m new file mode 100644 index 0000000..434a565 --- /dev/null +++ b/Week2/APLOCWeek2/APLOCWeek2/runEvent.m @@ -0,0 +1,57 @@ +// +// runEvent.m +// APLOCWeek2 +// +// Created by Brent Marohnic on 2/14/13. +// Copyright (c) 2013 Brent Marohnic. All rights reserved. +// + +#import "runEvent.h" + +@implementation runEvent + +@synthesize terrainType, eventDistance, eventName; + +// set unique data members from within INIT + +-(id)init +{ + self = [super init]; + if (self != nil) + { + [self setTerrainType:terrainEnum]; + [self setEventDistance:26]; + [self setEventName:@"Running"]; + } + return self; +} + +// override the base event method +// handicap equals a factor derived from the type of terrain on which the event occurs +// distanceHandicap equals the best training time for one mile * (distance * 1.05) + +-(float)calculateEventTime +{ + float handicap; + float distanceHandicap; + + if (terrainType == PAVEDESTREETS) + { + handicap = PAVEDESTREETS; + } + else if (terrainType == MIXEDSURFACE) + { + handicap = MIXEDSURFACE * (MIXEDSURFACE * 0.1); + } + else handicap = CROSSCOUNTRY * (CROSSCOUNTRY * 0.1); + + + distanceHandicap = 8 * (eventDistance * 1.05); + + [self setEventTimeInMinutes:(handicap + distanceHandicap)]; + + return self.eventTimeInMinutes; +} + + +@end diff --git a/Week2/APLOCWeek2/APLOCWeek2/swimEvent.h b/Week2/APLOCWeek2/APLOCWeek2/swimEvent.h new file mode 100644 index 0000000..7fe41f8 --- /dev/null +++ b/Week2/APLOCWeek2/APLOCWeek2/swimEvent.h @@ -0,0 +1,16 @@ +// +// swimEvent.h +// APLOCWeek2 +// +// Created by Brent Marohnic on 2/14/13. +// Copyright (c) 2013 Brent Marohnic. All rights reserved. +// + +#import "baseEvent.h" + +@interface swimEvent : baseEvent + +// event specific data members used to calculate event time +@property int waterTemp; + +@end diff --git a/Week2/APLOCWeek2/APLOCWeek2/swimEvent.m b/Week2/APLOCWeek2/APLOCWeek2/swimEvent.m new file mode 100644 index 0000000..de98b25 --- /dev/null +++ b/Week2/APLOCWeek2/APLOCWeek2/swimEvent.m @@ -0,0 +1,46 @@ +// +// swimEvent.m +// APLOCWeek2 +// +// Created by Brent Marohnic on 2/14/13. +// Copyright (c) 2013 Brent Marohnic. All rights reserved. +// + +#import "swimEvent.h" + +@implementation swimEvent + +@synthesize waterTemp, eventDistance, eventName; + +// set unique data members from within INIT + +-(id)init +{ + self = [super init]; + if (self != nil) + { + [self setWaterTemp:55]; + [self setEventDistance:3]; + [self setEventName:@"Swimming"]; + } + return self; +} + +// override the base event method +// handicap equals the (absolute value of (optimum water temp - water temp) * 0.1) * (absolute value of (optimum water temp - water temp) +// distanceHandicap equals the best training time for one mile * (distance * 1.1) + +-(float)calculateEventTime +{ + float handicap; + float distanceHandicap; + + handicap = abs(72 - waterTemp) * 0.1 * abs(72 - waterTemp); + distanceHandicap = 15 * (eventDistance * 1.1); + + [self setEventTimeInMinutes:(handicap + distanceHandicap)]; + + return self.eventTimeInMinutes; +} + +@end