mirror of https://github.com/nednal12/APLOC2.git
Completely Changed Direction
This commit is contained in:
parent
36d5d035b7
commit
0daff1acfa
Binary file not shown.
|
@ -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 = "<group>"; };
|
||||
65D407D816CD572700FAE85B /* ViewController2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewController2.h; sourceTree = "<group>"; };
|
||||
65D407D916CD572700FAE85B /* ViewController2.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewController2.m; sourceTree = "<group>"; };
|
||||
65D407DB16CDC19E00FAE85B /* baseEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = baseEvent.h; sourceTree = "<group>"; };
|
||||
65D407DC16CDC19E00FAE85B /* baseEvent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = baseEvent.m; sourceTree = "<group>"; };
|
||||
65D407DE16CDC5F400FAE85B /* swimEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = swimEvent.h; sourceTree = "<group>"; };
|
||||
65D407DF16CDC5F400FAE85B /* swimEvent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = swimEvent.m; sourceTree = "<group>"; };
|
||||
65D407E116CDD16B00FAE85B /* bikeEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bikeEvent.h; sourceTree = "<group>"; };
|
||||
65D407E216CDD16B00FAE85B /* bikeEvent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = bikeEvent.m; sourceTree = "<group>"; };
|
||||
65D407E416CDD3CE00FAE85B /* runEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = runEvent.h; sourceTree = "<group>"; };
|
||||
65D407E516CDD3CE00FAE85B /* runEvent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = runEvent.m; sourceTree = "<group>"; };
|
||||
65D407E716CDDA4300FAE85B /* eventFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = eventFactory.h; sourceTree = "<group>"; };
|
||||
65D407E816CDDA4300FAE85B /* eventFactory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = eventFactory.m; sourceTree = "<group>"; };
|
||||
/* 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 = "<group>";
|
||||
|
@ -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;
|
||||
};
|
||||
|
|
Binary file not shown.
|
@ -7,15 +7,16 @@
|
|||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#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
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
//
|
||||
// baseEvent.h
|
||||
// APLOCWeek2
|
||||
//
|
||||
// Created by Brent Marohnic on 2/14/13.
|
||||
// Copyright (c) 2013 Brent Marohnic. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,19 @@
|
|||
//
|
||||
// eventFactory.h
|
||||
// APLOCWeek2
|
||||
//
|
||||
// Created by Brent Marohnic on 2/14/13.
|
||||
// Copyright (c) 2013 Brent Marohnic. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "baseEvent.h"
|
||||
#import "swimEvent.h"
|
||||
#import "bikeEvent.h"
|
||||
#import "runEvent.h"
|
||||
|
||||
@interface eventFactory : NSObject
|
||||
|
||||
+(baseEvent *)createNewEvent:(int)eventType;
|
||||
|
||||
@end
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
Loading…
Reference in New Issue